]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add a clear() to SetIsh here so that the control/direct gets cleared
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 2 Aug 2013 17:01:32 +0000 (13:01 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 2 Aug 2013 17:01:32 +0000 (13:01 -0400)
before we do the pop() test.
- make clear()/pop() test unconditional

test/orm/test_collection.py

index fab2aac967fc35ac90558d1f129528f8ad2d2066..3a98da90fd4dc91a8131b232c2ed2cab672ef27c 100644 (file)
@@ -589,17 +589,19 @@ class CollectionsTest(fixtures.ORMTest):
             except TypeError:
                 assert True
 
-        if hasattr(direct, 'clear'):
-            addall(creator(), creator())
-            direct.clear()
-            control.clear()
-            assert_eq()
+        addall(creator(), creator())
+        direct.clear()
+        control.clear()
+        assert_eq()
 
-        if hasattr(direct, 'pop'):
-            addall(creator())
-            direct.pop()
-            control.pop()
-            assert_eq()
+        # note: the clear test previously needs
+        # to have executed in order for this to
+        # pass in all cases; else there's the possibility
+        # of non-deterministic behavior.
+        addall(creator())
+        direct.pop()
+        control.pop()
+        assert_eq()
 
         if hasattr(direct, 'difference_update'):
             zap()
@@ -812,6 +814,8 @@ class CollectionsTest(fixtures.ORMTest):
                 self.data.remove(item)
             def discard(self, item):
                 self.data.discard(item)
+            def clear(self):
+                self.data.clear()
             def pop(self):
                 return self.data.pop()
             def update(self, other):
@@ -844,6 +848,8 @@ class CollectionsTest(fixtures.ORMTest):
                 self.data.update(other)
             def __iter__(self):
                 return iter(self.data)
+            def clear(self):
+                self.data.clear()
             __hash__ = object.__hash__
             def __eq__(self, other):
                 return self.data == other