示例#1
0
def pytest_generate_tests(metafunc):
    tst_db = global_data['tst_db']
    bad_db = global_data['bad_db']

    tst_dbs = [tst_db]
    bad_dbs = [bad_db]

    if metafunc.config.getoption('complete'):
        tst = metafunc.module.__name__.split('.test_', 1)[-1]
        tst_conn = tst_db._conn
        bad_conn = bad_db._conn

        if tst in {'collection', 'document', 'graph', 'aql', 'index'}:
            # Add test transaction databases
            tst_txn_db = StandardDatabase(tst_conn)
            tst_txn_db._executor = TestTransactionExecutor(tst_conn)
            tst_txn_db._is_transaction = True
            tst_dbs.append(tst_txn_db)

            bad_txn_db = StandardDatabase(bad_conn)
            bad_txn_db._executor = TestTransactionExecutor(bad_conn)
            bad_dbs.append(bad_txn_db)

        if tst not in {'async', 'batch', 'transaction', 'client', 'exception'}:
            # Add test async databases
            tst_async_db = StandardDatabase(tst_conn)
            tst_async_db._executor = TestAsyncExecutor(tst_conn)
            tst_dbs.append(tst_async_db)

            bad_async_db = StandardDatabase(bad_conn)
            bad_async_db._executor = TestAsyncExecutor(bad_conn)
            bad_dbs.append(bad_async_db)

            # Add test batch databases
            tst_batch_db = StandardDatabase(tst_conn)
            tst_batch_db._executor = TestBatchExecutor(tst_conn)
            tst_dbs.append(tst_batch_db)

            bad_batch_bdb = StandardDatabase(bad_conn)
            bad_batch_bdb._executor = TestBatchExecutor(bad_conn)
            bad_dbs.append(bad_batch_bdb)

    if 'db' in metafunc.fixturenames and 'bad_db' in metafunc.fixturenames:
        metafunc.parametrize('db,bad_db', zip(tst_dbs, bad_dbs))

    elif 'db' in metafunc.fixturenames:
        metafunc.parametrize('db', tst_dbs)

    elif 'bad_db' in metafunc.fixturenames:
        metafunc.parametrize('bad_db', bad_dbs)
示例#2
0
def pytest_generate_tests(metafunc):
    test_name = metafunc.module.__name__.split('.test_', 1)[-1]

    dbs = [_db]
    bad_dbs = [_bad_db]

    if metafunc.config.getoption('complete'):

        if test_name in {'collection', 'document', 'graph', 'aql', 'index'}:
            # Add test transaction databases
            tdb = StandardDatabase(_db._conn)
            tdb._executor = TestTransactionExecutor(_db._conn)
            tdb._is_transaction = True
            dbs.append(tdb)

            bad_tdb = StandardDatabase(_bad_db._conn)
            bad_tdb._executor = TestTransactionExecutor(_bad_db._conn)
            bad_dbs.append(bad_tdb)

        if test_name not in {
                'async', 'batch', 'transaction', 'client', 'exception'
        }:
            # Add test async databases
            adb = StandardDatabase(_db._conn)
            adb._executor = TestAsyncExecutor(_db._conn)
            dbs.append(adb)

            bad_adb = StandardDatabase(_bad_db._conn)
            bad_adb._executor = TestAsyncExecutor(_bad_db._conn)
            bad_dbs.append(bad_adb)

            # Add test batch databases
            bdb = StandardDatabase(_db._conn)
            bdb._executor = TestBatchExecutor(_db._conn)
            dbs.append(bdb)

            bad_bdb = StandardDatabase(_bad_db._conn)
            bad_bdb._executor = TestBatchExecutor(_bad_db._conn)
            bad_dbs.append(bad_bdb)

    if 'db' in metafunc.fixturenames and 'bad_db' in metafunc.fixturenames:
        metafunc.parametrize('db,bad_db', zip(dbs, bad_dbs))
    elif 'db' in metafunc.fixturenames:
        metafunc.parametrize('db', dbs)
    elif 'bad_db' in metafunc.fixturenames:
        metafunc.parametrize('bad_db', bad_dbs)