Python sqlalchemy.testing.provide_metadata() Examples

The following are 1 code examples of sqlalchemy.testing.provide_metadata(). 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 sqlalchemy.testing , or try the search function .
Example #1
Source File: fixtures.py    From sqlalchemy with MIT License 5 votes vote down vote up
def connection(self):
        eng = getattr(self, "bind", config.db)
        conn = eng.connect()
        trans = conn.begin()
        try:
            yield conn
        finally:
            if trans.is_active:
                trans.rollback()
            conn.close()

    # propose a replacement for @testing.provide_metadata.
    # the problem with this is that TablesTest below has a ".metadata"
    # attribute already which is accessed directly as part of the
    # @testing.provide_metadata pattern.  Might need to call this _metadata
    # for it to be useful.
    # @config.fixture()
    # def metadata(self):
    #    """Provide bound MetaData for a single test, dropping afterwards."""
    #
    #    from . import engines
    #    metadata = schema.MetaData(config.db)
    #    try:
    #        yield metadata
    #    finally:
    #       engines.drop_all_tables(metadata, config.db)