]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Add a new le_() assertion for less than or equals
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 14 Jun 2015 20:42:14 +0000 (16:42 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 14 Jun 2015 20:42:14 +0000 (16:42 -0400)
- fix TablesTest to use the bind that we've returned from setup_bind()
to emit DELETE statements

lib/sqlalchemy/testing/__init__.py
lib/sqlalchemy/testing/assertions.py
lib/sqlalchemy/testing/fixtures.py

index adfbe85e301f21869d5501a2ce44fa42c047f2be..7482e32a1b149f3e931066de287cc9c15e58b436 100644 (file)
@@ -19,7 +19,7 @@ def against(*queries):
     return _against(config._current, *queries)
 
 from .assertions import emits_warning, emits_warning_on, uses_deprecated, \
-    eq_, ne_, is_, is_not_, startswith_, assert_raises, \
+    eq_, ne_, le_, is_, is_not_, startswith_, assert_raises, \
     assert_raises_message, AssertsCompiledSQL, ComparesTables, \
     AssertsExecutionResults, expect_deprecated, expect_warnings
 
index e5249c2969fe7b2efee730c057244cf18d6fb4c8..e0c02c896b5f043de460577c73f96b3796237cdc 100644 (file)
@@ -216,6 +216,11 @@ def ne_(a, b, msg=None):
     assert a != b, msg or "%r == %r" % (a, b)
 
 
+def le_(a, b, msg=None):
+    """Assert a <= b, with repr messaging on failure."""
+    assert a <= b, msg or "%r != %r" % (a, b)
+
+
 def is_(a, b, msg=None):
     """Assert a is b, with repr messaging on failure."""
     assert a is b, msg or "%r is not %r" % (a, b)
index 7b421952f9ecb69b1b852f288f1b39be8c7d13c9..e16bc77c0642245672d8ead55fb7b69f9715a205 100644 (file)
@@ -134,13 +134,14 @@ class TablesTest(TestBase):
     def _teardown_each_tables(self):
         # no need to run deletes if tables are recreated on setup
         if self.run_define_tables != 'each' and self.run_deletes == 'each':
-            for table in reversed(self.metadata.sorted_tables):
-                try:
-                    table.delete().execute().close()
-                except sa.exc.DBAPIError as ex:
-                    util.print_(
-                        ("Error emptying table %s: %r" % (table, ex)),
-                        file=sys.stderr)
+            with self.bind.connect() as conn:
+                for table in reversed(self.metadata.sorted_tables):
+                    try:
+                        conn.execute(table.delete())
+                    except sa.exc.DBAPIError as ex:
+                        util.print_(
+                            ("Error emptying table %s: %r" % (table, ex)),
+                            file=sys.stderr)
 
     def setup(self):
         self._setup_each_tables()