[Python-checkins] gh-98512: Add more tests for `ValuesView` (#98515)

JelleZijlstra webhook-mailer at python.org
Wed Nov 2 22:10:48 EDT 2022


https://github.com/python/cpython/commit/29e027c3e6535aa1c0eacc2fb2002c53405e1f6f
commit: 29e027c3e6535aa1c0eacc2fb2002c53405e1f6f
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-11-02T19:10:42-07:00
summary:

gh-98512: Add more tests for `ValuesView` (#98515)

files:
M Lib/test/test_collections.py
M Lib/test/test_dictviews.py

diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 1e398d6c3c7a..35ba5e97528b 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -1602,6 +1602,7 @@ def __len__(self):
         containers = [
             seq,
             ItemsView({1: nan, 2: obj}),
+            KeysView({1: nan, 2: obj}),
             ValuesView({1: nan, 2: obj})
         ]
         for container in containers:
@@ -1865,6 +1866,8 @@ def test_MutableMapping_subclass(self):
         mymap['red'] = 5
         self.assertIsInstance(mymap.keys(), Set)
         self.assertIsInstance(mymap.keys(), KeysView)
+        self.assertIsInstance(mymap.values(), Collection)
+        self.assertIsInstance(mymap.values(), ValuesView)
         self.assertIsInstance(mymap.items(), Set)
         self.assertIsInstance(mymap.items(), ItemsView)
 
diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py
index 7c48d800cd88..924f4a6829e1 100644
--- a/Lib/test/test_dictviews.py
+++ b/Lib/test/test_dictviews.py
@@ -338,6 +338,9 @@ def test_abc_registry(self):
         self.assertIsInstance(d.values(), collections.abc.ValuesView)
         self.assertIsInstance(d.values(), collections.abc.MappingView)
         self.assertIsInstance(d.values(), collections.abc.Sized)
+        self.assertIsInstance(d.values(), collections.abc.Collection)
+        self.assertIsInstance(d.values(), collections.abc.Iterable)
+        self.assertIsInstance(d.values(), collections.abc.Container)
 
         self.assertIsInstance(d.items(), collections.abc.ItemsView)
         self.assertIsInstance(d.items(), collections.abc.MappingView)



More information about the Python-checkins mailing list