From b60f387b7c594ddc95da9897cf90f139af56c561 Mon Sep 17 00:00:00 2001 From: stepan Date: Thu, 25 Mar 2021 23:16:03 +0100 Subject: [PATCH] Fix assertion of pop() result in test_issue_4920 The pop method of MutableSet iterates the underlying set object to choose the item to remove. According the the Python language reference "sets do not record element position or order of insertion". Changes the test to not assert concrete result of pop, but just that it was an item from the set, and that the set shrunk by one. --- Lib/test/test_collections.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 30303f00ba5c175..7b245c08b5ddd3a 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -1512,8 +1512,12 @@ def discard(self,v): return result def __repr__(self): return "MySet(%s)" % repr(list(self)) - s = MySet([5,43,2,1]) - self.assertEqual(s.pop(), 1) + items = [5,43,2,1] + s = MySet(items) + r = s.pop() + self.assertEquals(len(s), len(items) - 1) + self.assertNotIn(r, s) + self.assertIn(r, items) def test_issue8750(self): empty = WithSet()