diff options
author | Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> | 2020-06-10 05:56:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-10 05:56:56 (GMT) |
commit | 07d81128124f2b574808e33267c38b104b42ae2a (patch) | |
tree | f099a32436e70dcab4083a302fbc2b6cb604cdfd /Lib/test/test_dict.py | |
parent | bae872f1fe9b3a0d3e3b8800a2ac8d6b440d6e4d (diff) | |
download | cpython-07d81128124f2b574808e33267c38b104b42ae2a.zip cpython-07d81128124f2b574808e33267c38b104b42ae2a.tar.gz cpython-07d81128124f2b574808e33267c38b104b42ae2a.tar.bz2 |
bpo-40889: Optimize dict.items() ^ dict.items() (GH-20718)
Diffstat (limited to 'Lib/test/test_dict.py')
-rw-r--r-- | Lib/test/test_dict.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index 6b8596f..5c08810 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -697,6 +697,16 @@ class DictTest(unittest.TestCase): self.assertEqual(k1 ^ k2, {(3,3)}) self.assertEqual(k1 ^ k3, {(1,1), (2,2), (4,4)}) + def test_items_symmetric_difference(self): + rr = random.randrange + for _ in range(100): + left = {x:rr(3) for x in range(20) if rr(2)} + right = {x:rr(3) for x in range(20) if rr(2)} + with self.subTest(left=left, right=right): + expected = set(left.items()) ^ set(right.items()) + actual = left.items() ^ right.items() + self.assertEqual(actual, expected) + def test_dictview_mixed_set_operations(self): # Just a few for .keys() self.assertTrue({1:1}.keys() == {1}) |