summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2019-10-06 11:28:33 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-10-06 11:28:33 (GMT)
commitc38e725d17537b20ff090b1b5ec7db1820ff9b63 (patch)
tree43538ff0c73adcfe30a7db8d28af1a2e24c93436 /Lib
parent65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd (diff)
downloadcpython-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.py11
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()