当前位置: 首页>>代码示例>>Python>>正文


Python testing.db方法代码示例

本文整理汇总了Python中sqlalchemy.testing.db方法的典型用法代码示例。如果您正苦于以下问题:Python testing.db方法的具体用法?Python testing.db怎么用?Python testing.db使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.testing的用法示例。


在下文中一共展示了testing.db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_run_transaction

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def test_run_transaction(self):
        def callback(barrier):
            Session = sessionmaker(testing.db)

            def txn_body(session):
                accounts = list(session.query(Account)
                                .filter(Account.acct.in_((1, 2)))
                                .order_by(Account.acct))
                barrier()
                if accounts[0].balance > accounts[1].balance:
                    accounts[0].balance -= 100
                    accounts[1].balance += 100
                else:
                    accounts[0].balance += 100
                    accounts[1].balance -= 100
            run_transaction(Session, txn_body)
        self.run_parallel_transactions(callback) 
开发者ID:cockroachdb,项目名称:sqlalchemy-cockroachdb,代码行数:19,代码来源:test_run_transaction.py

示例2: test_has_table

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def test_has_table(self):
        with config.db.begin() as conn:
            assert config.db.dialect.has_table(conn, "test_table")
            assert not config.db.dialect.has_table(conn, "nonexistent_table") 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:test_reflection.py

示例3: test_get_schema_names

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def test_get_schema_names(self):
        insp = inspect(testing.db)

        self.assert_(testing.config.test_schema in insp.get_schema_names()) 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:test_reflection.py

示例4: test_get_default_schema_name

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def test_get_default_schema_name(self):
        insp = inspect(testing.db)
        eq_(insp.default_schema_name, testing.db.dialect.default_schema_name) 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:test_reflection.py

示例5: _engine_uri

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def _engine_uri(options, file_config):
    from sqlalchemy.testing import config
    from sqlalchemy import testing
    from sqlalchemy.testing import provision

    if options.dburi:
        db_urls = list(options.dburi)
    else:
        db_urls = []

    if options.db:
        for db_token in options.db:
            for db in re.split(r'[,\s]+', db_token):
                if db not in file_config.options('db'):
                    raise RuntimeError(
                        "Unknown URI specifier '%s'.  "
                        "Specify --dbs for known uris."
                        % db)
                else:
                    db_urls.append(file_config.get('db', db))

    if not db_urls:
        db_urls.append(file_config.get('db', 'default'))

    for db_url in db_urls:
        cfg = provision.setup_config(
            db_url, options, file_config, provision.FOLLOWER_IDENT)

        if not config._current:
            cfg.set_as_current(cfg, testing) 
开发者ID:jpush,项目名称:jbox,代码行数:32,代码来源:plugin_base.py

示例6: generate_sub_tests

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def generate_sub_tests(cls, module):
    if getattr(cls, '__backend__', False):
        for cfg in _possible_configs_for_cls(cls):
            name = "%s_%s_%s" % (cls.__name__, cfg.db.name, cfg.db.driver)
            subcls = type(
                name,
                (cls, ),
                {
                    "__only_on__": ("%s+%s" % (cfg.db.name, cfg.db.driver)),
                }
            )
            setattr(module, name, subcls)
            yield subcls
    else:
        yield cls 
开发者ID:jpush,项目名称:jbox,代码行数:17,代码来源:plugin_base.py

示例7: stop_test_class

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def stop_test_class(cls):
    #from sqlalchemy import inspect
    #assert not inspect(testing.db).get_table_names()
    engines.testing_reaper._stop_test_ctx()
    try:
        if not options.low_connections:
            assertions.global_cleanup_assertions()
    finally:
        _restore_engine() 
开发者ID:jpush,项目名称:jbox,代码行数:11,代码来源:plugin_base.py

示例8: before_test

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def before_test(test, test_module_name, test_class, test_name):

    # like a nose id, e.g.:
    # "test.aaa_profiling.test_compiler.CompileTest.test_update_whereclause"
    name = test_class.__name__

    suffix = "_%s_%s" % (config.db.name, config.db.driver)
    if name.endswith(suffix):
        name = name[0:-(len(suffix))]

    id_ = "%s.%s.%s" % (test_module_name, name, test_name)

    profiling._current_test = id_ 
开发者ID:jpush,项目名称:jbox,代码行数:15,代码来源:plugin_base.py

示例9: stop_test_class

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def stop_test_class(cls):
    #from sqlalchemy import inspect
    #assert not inspect(testing.db).get_table_names()
    engines.testing_reaper._stop_test_ctx()
    if not options.low_connections:
        assertions.global_cleanup_assertions()
    _restore_engine() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:plugin_base.py

示例10: _test_get_comments

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def _test_get_comments(self, schema=None):
        insp = inspect(testing.db)

        eq_(
            insp.get_table_comment("comment_test", schema=schema),
            {"text": r"""the test % ' " \ table comment"""}
        )

        eq_(
            insp.get_table_comment("users", schema=schema),
            {"text": None}
        )

        eq_(
            [
                {"name": rec['name'], "comment": rec['comment']}
                for rec in
                insp.get_columns("comment_test", schema=schema)
            ],
            [
                {'comment': 'id comment', 'name': 'id'},
                {'comment': 'data % comment', 'name': 'data'},
                {'comment': r"""Comment types type speedily ' " \ '' Fun!""",
                 'name': 'd2'}
            ]
        ) 
开发者ID:yfauser,项目名称:planespotter,代码行数:28,代码来源:test_reflection.py

示例11: test_get_table_names

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def test_get_table_names(self):
        tablenames = [
            t for t in inspect(testing.db).get_table_names()
            if t.lower() in ("t1", "t2")]

        eq_(tablenames[0].upper(), tablenames[0].lower())
        eq_(tablenames[1].upper(), tablenames[1].lower()) 
开发者ID:yfauser,项目名称:planespotter,代码行数:9,代码来源:test_reflection.py

示例12: _list_dbs

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def _list_dbs(*args):
    print("Available --db options (use --dburi to override)")
    for macro in sorted(file_config.options('db')):
        print("%20s\t%s" % (macro, file_config.get('db', macro)))
    sys.exit(0) 
开发者ID:yfauser,项目名称:planespotter,代码行数:7,代码来源:plugin_base.py

示例13: _engine_uri

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def _engine_uri(options, file_config):
    from sqlalchemy.testing import config
    from sqlalchemy import testing
    from sqlalchemy.testing import provision

    if options.dburi:
        db_urls = list(options.dburi)
    else:
        db_urls = []

    if options.db:
        for db_token in options.db:
            for db in re.split(r'[,\s]+', db_token):
                if db not in file_config.options('db'):
                    raise RuntimeError(
                        "Unknown URI specifier '%s'.  "
                        "Specify --dbs for known uris."
                        % db)
                else:
                    db_urls.append(file_config.get('db', db))

    if not db_urls:
        db_urls.append(file_config.get('db', 'default'))

    config._current = None
    for db_url in db_urls:

        if options.write_idents and provision.FOLLOWER_IDENT: # != 'master':
            with open(options.write_idents, "a") as file_:
                file_.write(provision.FOLLOWER_IDENT + " " + db_url + "\n")

        cfg = provision.setup_config(
            db_url, options, file_config, provision.FOLLOWER_IDENT)

        if not config._current:
            cfg.set_as_current(cfg, testing) 
开发者ID:yfauser,项目名称:planespotter,代码行数:38,代码来源:plugin_base.py

示例14: test_reflect_lowercase_forced_tables

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def test_reflect_lowercase_forced_tables(self):

        m2 = MetaData(testing.db)
        t2_ref = Table(quoted_name('t2', quote=True), m2, autoload=True)
        t1_ref = m2.tables['t1']
        assert t2_ref.c.t1id.references(t1_ref.c.id)

        m3 = MetaData(testing.db)
        m3.reflect(only=lambda name, m: name.lower() in ('t1', 't2'))
        assert m3.tables['t2'].c.t1id.references(m3.tables['t1'].c.id) 
开发者ID:eirannejad,项目名称:pyRevit,代码行数:12,代码来源:test_reflection.py

示例15: _engine_uri

# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import db [as 别名]
def _engine_uri(options, file_config):
    from sqlalchemy.testing import config
    from sqlalchemy import testing
    from sqlalchemy.testing import provision

    if options.dburi:
        db_urls = list(options.dburi)
    else:
        db_urls = []

    if options.db:
        for db_token in options.db:
            for db in re.split(r'[,\s]+', db_token):
                if db not in file_config.options('db'):
                    raise RuntimeError(
                        "Unknown URI specifier '%s'.  "
                        "Specify --dbs for known uris."
                        % db)
                else:
                    db_urls.append(file_config.get('db', db))

    if not db_urls:
        db_urls.append(file_config.get('db', 'default'))

    config._current = None
    for db_url in db_urls:
        cfg = provision.setup_config(
            db_url, options, file_config, provision.FOLLOWER_IDENT)

        if not config._current:
            cfg.set_as_current(cfg, testing) 
开发者ID:eirannejad,项目名称:pyRevit,代码行数:33,代码来源:plugin_base.py


注:本文中的sqlalchemy.testing.db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。