From: Mike Bayer Date: Sun, 9 Nov 2014 17:33:26 +0000 (-0500) Subject: - add some connection cleanup X-Git-Tag: rel_0_7_0~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9abd572c70c09114313dc7349783378f54690c98;p=thirdparty%2Fsqlalchemy%2Falembic.git - add some connection cleanup --- diff --git a/tests/test_autogenerate.py b/tests/test_autogenerate.py index 9f6cc002..e9951a76 100644 --- a/tests/test_autogenerate.py +++ b/tests/test_autogenerate.py @@ -58,7 +58,7 @@ class AutogenTest(object): clear_staging_env() def setUp(self): - conn = self.bind.connect() + self.conn = conn = self.bind.connect() ctx_opts = { 'compare_type': True, 'compare_server_default': True, @@ -83,6 +83,9 @@ class AutogenTest(object): 'context': context } + def tearDown(self): + self.conn.close() + class AutogenFixtureTest(object): diff --git a/tests/test_batch.py b/tests/test_batch.py index bbbb0943..0d5edd6b 100644 --- a/tests/test_batch.py +++ b/tests/test_batch.py @@ -355,8 +355,9 @@ class BatchRoundTripTest(TestBase): def setUp(self): self.conn = config.db.connect() + self.metadata = MetaData() t1 = Table( - 'foo', MetaData(), + 'foo', self.metadata, Column('id', Integer, primary_key=True), Column('data', String(50)), Column('x', Integer) @@ -377,7 +378,7 @@ class BatchRoundTripTest(TestBase): self.op = Operations(context) def tearDown(self): - self.conn.execute("drop table foo") + self.metadata.drop_all(self.conn) self.conn.close() def _assert_data(self, data): diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index f1b2c2d5..908eec6d 100644 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -319,9 +319,10 @@ class PostgresqlDetectSerialTest(TestBase): @classmethod def setup_class(cls): cls.bind = config.db + cls.conn = cls.bind.connect() staging_env() context = MigrationContext.configure( - connection=cls.bind.connect(), + connection=cls.conn, opts={ 'compare_type': True, 'compare_server_default': True @@ -343,6 +344,7 @@ class PostgresqlDetectSerialTest(TestBase): @classmethod def teardown_class(cls): + cls.conn.close() clear_staging_env() @provide_metadata