]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
oops! python 3 doesn't do the rich comparison cmp thing
authorDiana Clarke <diana.joan.clarke@gmail.com>
Thu, 15 Nov 2012 04:25:09 +0000 (23:25 -0500)
committerDiana Clarke <diana.joan.clarke@gmail.com>
Thu, 15 Nov 2012 04:25:09 +0000 (23:25 -0500)
test/base/test_utils.py

index 06a91b62bccb2c10a605534dd7f17f2c2d40ddd9..8f5bffd436055b5edeb3f928cd852d490576e8f5 100644 (file)
@@ -345,8 +345,7 @@ class IdentitySetTest(fixtures.TestBase):
         def should_raise():
             not_an_identity_set = object()
             return unique1 <= not_an_identity_set
-        assert_raises_message(
-            TypeError, 'cannot compare sets using cmp()', should_raise)
+        self._assert_unorderable_types(should_raise)
 
     def test_dunder_lt(self):
         super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
@@ -367,8 +366,7 @@ class IdentitySetTest(fixtures.TestBase):
         def should_raise():
             not_an_identity_set = object()
             return unique1 < not_an_identity_set
-        assert_raises_message(
-            TypeError, 'cannot compare sets using cmp()', should_raise)
+        self._assert_unorderable_types(should_raise)
 
     def test_dunder_ge(self):
         super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
@@ -389,8 +387,7 @@ class IdentitySetTest(fixtures.TestBase):
         def should_raise():
             not_an_identity_set = object()
             return unique1 >= not_an_identity_set
-        assert_raises_message(
-            TypeError, 'cannot compare sets using cmp()', should_raise)
+        self._assert_unorderable_types(should_raise)
 
     def test_dunder_gt(self):
         super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
@@ -411,8 +408,7 @@ class IdentitySetTest(fixtures.TestBase):
         def should_raise():
             not_an_identity_set = object()
             return unique1 > not_an_identity_set
-        assert_raises_message(
-            TypeError, 'cannot compare sets using cmp()', should_raise)
+        self._assert_unorderable_types(should_raise)
 
     def test_issubset(self):
         super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
@@ -712,6 +708,15 @@ class IdentitySetTest(fixtures.TestBase):
         unique2 = util.IdentitySet([o5])
         return super_, sub_, twin1, twin2, unique1, unique2
 
+    def _assert_unorderable_types(self, callable_):
+        # Py3K
+        #assert_raises_message(
+        #    TypeError, 'unorderable types', callable_)
+        # Py2K
+        assert_raises_message(
+            TypeError, 'cannot compare sets using cmp()', callable_)
+        # end Py2K
+
     def test_basic_sanity(self):
         IdentitySet = util.IdentitySet