def test_table_singleton_a(self): """set up for table singleton check """ # # For this 'test', create a proxy engine instance, connect it # to a real engine, and make it do some work # engine = ProxyEngine() cats = Table('cats', engine, Column('cat_id', Integer, primary_key=True), Column('cat_name', String)) engine.connect(testbase.db_uri) cats.create(engine) cats.drop(engine) ProxyEngineTest2.cats_table_a = cats assert isinstance(cats, Table)
def test_table_singleton_a(self): """set up for table singleton check """ # # For this 'test', create a proxy engine instance, connect it # to a real engine, and make it do some work # engine = ProxyEngine() cats = Table('cats', engine, Column('cat_id', Integer, primary_key=True), Column('cat_name', String)) engine.connect(testbase.db_uri) cats.create(engine) cats.drop(engine) ProxyEngineTest2.cats_table_a = cats assert isinstance(cats, Table)
def test_table_singleton_b(self): """check that a table on a 2nd proxy engine instance gets 2nd table instance """ # # Now create a new proxy engine instance and attach the same # table as the first test. This should result in 2 table instances, # since different proxy engine instances can't attach to the # same table instance # engine = ProxyEngine() cats = Table('cats', engine, Column('cat_id', Integer, primary_key=True), Column('cat_name', String)) assert id(cats) != id(ProxyEngineTest2.cats_table_a) # the real test -- if we're still using the old engine reference, # this will fail because the old reference's local storage will # not have the default attributes engine.connect(testbase.db_uri) cats.create(engine) cats.drop(engine)
def test_table_singleton_b(self): """check that a table on a 2nd proxy engine instance gets 2nd table instance """ # # Now create a new proxy engine instance and attach the same # table as the first test. This should result in 2 table instances, # since different proxy engine instances can't attach to the # same table instance # engine = ProxyEngine() cats = Table('cats', engine, Column('cat_id', Integer, primary_key=True), Column('cat_name', String)) assert id(cats) != id(ProxyEngineTest2.cats_table_a) # the real test -- if we're still using the old engine reference, # this will fail because the old reference's local storage will # not have the default attributes engine.connect(testbase.db_uri) cats.create(engine) cats.drop(engine)