From: Mike Bayer Date: Fri, 2 Aug 2013 17:01:32 +0000 (-0400) Subject: - add a clear() to SetIsh here so that the control/direct gets cleared X-Git-Tag: rel_0_9_0b1~152 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=31ec1fc85eda517c2bc70fd4c9bbd4d51a2546a6;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - add a clear() to SetIsh here so that the control/direct gets cleared before we do the pop() test. - make clear()/pop() test unconditional --- diff --git a/test/orm/test_collection.py b/test/orm/test_collection.py index fab2aac967..3a98da90fd 100644 --- a/test/orm/test_collection.py +++ b/test/orm/test_collection.py @@ -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