Python tests.BaseTestCase() Examples

The following are 3 code examples of tests.BaseTestCase(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tests , or try the search function .
Example #1
Source File: test_plugins.py    From mistune with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def load_plugin(plugin_name, ast=False):
    _plugin = getattr(plugins, 'plugin_{}'.format(plugin_name))

    class TestPlugin(BaseTestCase):
        md = Markdown(
            renderer=HTMLRenderer(escape=False),
            plugins=[_plugin]
        )

    def test_ast_renderer(self):
        md = Markdown(renderer=AstRenderer(), plugins=[_plugin])
        data = fixtures.load_json(plugin_name + '.json')
        self.assertEqual(md(data['text']), data['tokens'])

    if ast:
        test_ast_renderer.__doc__ = 'Run {} ast renderer'.format(plugin_name)
        setattr(TestPlugin, 'test_ast_renderer', test_ast_renderer)

    TestPlugin.load_fixtures(plugin_name + '.txt')
    globals()['TestPlugin_' + plugin_name] = TestPlugin 
Example #2
Source File: test_unstable_connection.py    From TorMySQL with MIT License 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.PARAMS = dict(self.PARAMS)
        self.host, self.port = self.PARAMS['host'], self.PARAMS['port'] 
Example #3
Source File: test_unstable_connection.py    From TorMySQL with MIT License 5 votes vote down vote up
def tearDown(self):
        try:
            for request in TestThroughProxy.proxys:
                request.conn.end()
            self.proxy_server.close()
        except:
            pass
        super(BaseTestCase, self).tearDown()