summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-08-08 17:12:28 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-08-08 17:12:28 (GMT)
commit2532635fcd30f250fe4dce6a3e0cfd0331c92520 (patch)
tree892e8793a515ef88e185a28d5c7e232c3afc04ca
parent4e4f3b8d353803003c5f114a29f3b0ab1596fe24 (diff)
downloadcpython-2532635fcd30f250fe4dce6a3e0cfd0331c92520.zip
cpython-2532635fcd30f250fe4dce6a3e0cfd0331c92520.tar.gz
cpython-2532635fcd30f250fe4dce6a3e0cfd0331c92520.tar.bz2
#18357: add tests for dictview set difference. Patch by Fraser Tweedale.
-rw-r--r--Lib/test/test_dictviews.py14
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
3 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py
index ac8bfe6..7b02ea9 100644
--- a/Lib/test/test_dictviews.py
+++ b/Lib/test/test_dictviews.py
@@ -112,6 +112,13 @@ class DictSetTest(unittest.TestCase):
self.assertEqual(d1.keys() ^ set(d3.keys()),
{'a', 'b', 'd', 'e'})
+ self.assertEqual(d1.keys() - d1.keys(), set())
+ self.assertEqual(d1.keys() - d2.keys(), {'a'})
+ self.assertEqual(d1.keys() - d3.keys(), {'a', 'b'})
+ self.assertEqual(d1.keys() - set(d1.keys()), set())
+ self.assertEqual(d1.keys() - set(d2.keys()), {'a'})
+ self.assertEqual(d1.keys() - set(d3.keys()), {'a', 'b'})
+
self.assertFalse(d1.keys().isdisjoint(d1.keys()))
self.assertFalse(d1.keys().isdisjoint(d2.keys()))
self.assertFalse(d1.keys().isdisjoint(list(d2.keys())))
@@ -162,6 +169,13 @@ class DictSetTest(unittest.TestCase):
self.assertEqual(d1.items() ^ d3.items(),
{('a', 1), ('b', 2), ('d', 4), ('e', 5)})
+ self.assertEqual(d1.items() - d1.items(), set())
+ self.assertEqual(d1.items() - d2.items(), {('a', 1)})
+ self.assertEqual(d1.items() - d3.items(), {('a', 1), ('b', 2)})
+ self.assertEqual(d1.items() - set(d1.items()), set())
+ self.assertEqual(d1.items() - set(d2.items()), {('a', 1)})
+ self.assertEqual(d1.items() - set(d3.items()), {('a', 1), ('b', 2)})
+
self.assertFalse(d1.items().isdisjoint(d1.items()))
self.assertFalse(d1.items().isdisjoint(d2.items()))
self.assertFalse(d1.items().isdisjoint(list(d2.items())))
diff --git a/Misc/ACKS b/Misc/ACKS
index 2279417..2d3b929 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1252,6 +1252,7 @@ David Turner
Stephen Turner
Theodore Turocy
Bill Tutt
+Fraser Tweedale
Doobee R. Tzeck
Eren Türkay
Lionel Ulmer
diff --git a/Misc/NEWS b/Misc/NEWS
index 2550dc4..d6a645d 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -237,6 +237,9 @@ IDLE
Tests
-----
+- Issue #18357: add tests for dictview set difference.
+ Patch by Fraser Tweedale.
+
- Issue #18273: move the tests in Lib/test/json_tests to Lib/test/test_json
and make them discoverable by unittest. Patch by Zachary Ware.