From 8fc0576b6c2c9ab20f2f81d5df6182c5cd45fc38 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 31 Mar 2009 20:54:10 +0000 Subject: [PATCH] a myriad of close_first calls to get sql.alltests to run --- test/engine/execute.py | 2 ++ test/sql/functions.py | 6 +++++- test/sql/labels.py | 1 + test/sql/query.py | 7 ++++++- test/sql/testtypes.py | 4 ++++ test/sql/unicode.py | 1 + test/testlib/engines.py | 10 +++++++++- 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/test/engine/execute.py b/test/engine/execute.py index 9d9a57e7c0..f41d401c6a 100644 --- a/test/engine/execute.py +++ b/test/engine/execute.py @@ -18,8 +18,10 @@ class ExecuteTest(TestBase): ) metadata.create_all() + @engines.close_first def tearDown(self): testing.db.connect().execute(users.delete()) + def tearDownAll(self): metadata.drop_all() diff --git a/test/sql/functions.py b/test/sql/functions.py index 1519575036..9c61617fc6 100644 --- a/test/sql/functions.py +++ b/test/sql/functions.py @@ -180,7 +180,10 @@ class CompileTest(TestBase, AssertsCompiledSQL): class ExecuteTest(TestBase): - + @engines.close_first + def tearDown(self): + pass + def test_standalone_execute(self): x = testing.db.func.current_date().execute().scalar() y = testing.db.func.current_date().select().execute().scalar() @@ -202,6 +205,7 @@ class ExecuteTest(TestBase): conn.close() assert (x == y == z) is True + @engines.close_first def test_update(self): """ Tests sending functions and SQL expressions to the VALUES and SET diff --git a/test/sql/labels.py b/test/sql/labels.py index 94ee20342e..39493e8b81 100644 --- a/test/sql/labels.py +++ b/test/sql/labels.py @@ -34,6 +34,7 @@ class LongLabelsTest(TestBase, AssertsCompiledSQL): maxlen = testing.db.dialect.max_identifier_length testing.db.dialect.max_identifier_length = IDENT_LENGTH + @engines.close_first def tearDown(self): table1.delete().execute() diff --git a/test/sql/query.py b/test/sql/query.py index 700b2ca5f6..b124428c63 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -26,6 +26,7 @@ class QueryTest(TestBase): ) metadata.create_all() + @engines.close_first def tearDown(self): addresses.delete().execute() users.delete().execute() @@ -879,7 +880,11 @@ class CompoundTest(TestBase): dict(col2="t3col2r2", col3="bbb", col4="aaa"), dict(col2="t3col2r3", col3="ccc", col4="bbb"), ]) - + + @engines.close_first + def tearDown(self): + pass + def tearDownAll(self): metadata.drop_all() diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index 74883cafa3..e11810f5f3 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -308,6 +308,7 @@ class UnicodeTest(TestBase, AssertsExecutionResults): def tearDownAll(self): metadata.drop_all() + @engines.close_first def tearDown(self): unicode_table.delete().execute() @@ -405,6 +406,7 @@ class BinaryTest(TestBase, AssertsExecutionResults): ) binary_table.create() + @engines.close_first def tearDown(self): binary_table.delete().execute() @@ -691,6 +693,7 @@ class NumericTest(TestBase, AssertsExecutionResults): def tearDownAll(self): metadata.drop_all() + @engines.close_first def tearDown(self): numeric_table.delete().execute() @@ -764,6 +767,7 @@ class IntervalTest(TestBase, AssertsExecutionResults): ) metadata.create_all() + @engines.close_first def tearDown(self): interval_table.delete().execute() diff --git a/test/sql/unicode.py b/test/sql/unicode.py index c5002aaffb..d0e4017b14 100644 --- a/test/sql/unicode.py +++ b/test/sql/unicode.py @@ -56,6 +56,7 @@ class UnicodeSchemaTest(TestBase): ) metadata.create_all() + @engines.close_first def tearDown(self): if metadata.tables: t3.delete().execute() diff --git a/test/testlib/engines.py b/test/testlib/engines.py index 44e6ad96a0..86c1944788 100644 --- a/test/testlib/engines.py +++ b/test/testlib/engines.py @@ -39,7 +39,7 @@ class ConnectionKiller(object): testing_reaper = ConnectionKiller() def drop_all_tables(metadata): - testing_reaper.rollback_all() + testing_reaper.close_all() metadata.drop_all() def assert_conns_closed(fn): @@ -60,6 +60,14 @@ def rollback_open_connections(fn): testing_reaper.rollback_all() return _function_named(decorated, fn.__name__) +def close_first(fn): + """Decorator that closes all connections before fn execution.""" + def decorated(*args, **kw): + testing_reaper.close_all() + fn(*args, **kw) + return _function_named(decorated, fn.__name__) + + def close_open_connections(fn): """Decorator that closes all connections after fn execution.""" -- 2.47.3