def __init__(self, provider_name, *args, **kwargs):
        kwargs['pony_check_connection'] = False
        kwargs['pony_pool_mockup'] = TestPool()
        if self.real_provider_name is not None:
            provider_name = self.real_provider_name
        provider_module = import_module('pony.orm.dbproviders.' + provider_name)
        provider_cls = provider_module.provider_cls
        raw_server_version = self.raw_server_version

        if raw_server_version is None:
            if provider_name == 'sqlite': raw_server_version = '3.7.17'
            elif provider_name in ('postgres', 'pygresql'): raw_server_version = '9.2'
            elif provider_name == 'oracle': raw_server_version = '11.2.0.2.0'
            elif provider_name == 'mysql': raw_server_version = '5.6.11'
            else: assert False, provider_name

        t = map(int, raw_server_version.split('.'))
        if len(t) == 2: t.append(0)
        server_version = tuple(t)
        if provider_name in ('postgres', 'pygresql'):
            server_version = int('%d%02d%02d' % server_version)

        class TestProvider(provider_cls):
            def inspect_connection(provider, connection):
                pass
        TestProvider.server_version = server_version

        Database.__init__(self, TestProvider, *args, **kwargs)
Exemple #2
0
 def __init__(self, provider_name, *args, **kwargs):
     kwargs['pony_check_connection'] = False
     kwargs['pony_pool_mockup'] = TestPool()
     Database.__init__(self, self.real_provider_name or provider_name, *args, **kwargs)