diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2019-10-06 11:28:33 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-10-06 11:28:33 (GMT) |
commit | c38e725d17537b20ff090b1b5ec7db1820ff9b63 (patch) | |
tree | 43538ff0c73adcfe30a7db8d28af1a2e24c93436 /Lib | |
parent | 65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd (diff) | |
download | cpython-c38e725d17537b20ff090b1b5ec7db1820ff9b63.zip cpython-c38e725d17537b20ff090b1b5ec7db1820ff9b63.tar.gz cpython-c38e725d17537b20ff090b1b5ec7db1820ff9b63.tar.bz2 |
bpo-38210: Fix intersection operation with dict view and iterator. (GH-16602)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_dictviews.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py index b15cfeb..7cf0192 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -214,6 +214,17 @@ class DictSetTest(unittest.TestCase): self.assertTrue(de.items().isdisjoint(de.items())) self.assertTrue(de.items().isdisjoint([1])) + def test_set_operations_with_iterator(self): + origin = {1: 2, 3: 4} + self.assertEqual(origin.keys() & iter([1, 2]), {1}) + self.assertEqual(origin.keys() | iter([1, 2]), {1, 2, 3}) + self.assertEqual(origin.keys() ^ iter([1, 2]), {2, 3}) + + items = origin.items() + self.assertEqual(items & iter([(1, 2)]), {(1, 2)}) + self.assertEqual(items ^ iter([(1, 2)]), {(3, 4)}) + self.assertEqual(items | iter([(1, 2)]), {(1, 2), (3, 4)}) + def test_recursive_repr(self): d = {} d[42] = d.values() |