コード例 #1
0
ファイル: test_web.py プロジェクト: pytest-dev/plugincompat
def storage(request):
    """
    Initializes a Storage for execution in a test environment. This fixture
    will instantiate the storage class given in the parameters. This way we
    ensure both the real implementation and dummy implementation work in the
    same way.

    When initializing the real PlugsStorage(), it will use a test-specific
    data-base to avoid any conflicts between tests and to avoid clashing with
    real databases.
    """
    if request.param is PlugsStorage:
        db_name = "testing-{}".format(request.node.name)

        plugs_storage = PlugsStorage(default_db_name=db_name)
        plugs_storage.__TESTING__ = True

        def finalizer():
            plugs_storage.get_connection().drop_database(db_name)

        request.addfinalizer(finalizer)
        return plugs_storage
    elif request.param is MemoryStorage:
        memory_storage = MemoryStorage()
        return memory_storage
    else:
        assert False
コード例 #2
0
ファイル: test_web.py プロジェクト: adamchainz/plugincompat
def storage(request):
    """
    Initializes a Storage for execution in a test environment. This fixture
    will instantiate the storage class given in the parameters. This way we
    ensure both the real implementation and dummy implementation work in the
    same way.

    When initializing the real PlugsStorage(), it will use a test-specific
    data-base to avoid any conflicts between tests and to avoid clashing with
    real databases.
    """
    if request.param is PlugsStorage:
        db_name = 'testing-{}'.format(request.node.name)

        plugs_storage = PlugsStorage(default_db_name=db_name)
        plugs_storage.__TESTING__ = True

        def finalizer():
            plugs_storage.get_connection().drop_database(db_name)

        request.addfinalizer(finalizer)
        return plugs_storage
    elif request.param is MemoryStorage:
        memory_storage = MemoryStorage()
        return memory_storage
    else:
        assert False
コード例 #3
0
ファイル: drop_db.py プロジェクト: adamchainz/plugincompat
from web import PlugsStorage
s=PlugsStorage()
s.drop_all()
print 'Database dropped'

コード例 #4
0
from web import PlugsStorage

s = PlugsStorage()
s.drop_all()
print("Database dropped")
コード例 #5
0
ファイル: test_web.py プロジェクト: nicoddemus/plugincompat
def storage():
    with PlugsStorage("sqlite:///:memory:") as st:
        yield st