From 31ec1fc85eda517c2bc70fd4c9bbd4d51a2546a6 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 2 Aug 2013 13:01:32 -0400 Subject: [PATCH] - add a clear() to SetIsh here so that the control/direct gets cleared before we do the pop() test. - make clear()/pop() test unconditional --- test/orm/test_collection.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) 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 -- 2.47.3