From 7a117865cdbb43d1dc4be004f2f864b3a52c6e33 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Thu, 3 Nov 2022 05:10:42 +0300 Subject: [PATCH] gh-98512: Add more tests for `ValuesView` (GH-98515) (cherry picked from commit 29e027c3e6535aa1c0eacc2fb2002c53405e1f6f) Co-authored-by: Nikita Sobolev --- Lib/test/test_collections.py | 3 +++ Lib/test/test_dictviews.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 3404b8ad1bcf73..17afda415bb240 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -1580,6 +1580,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: @@ -1843,6 +1844,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 be271bebaaf1ff..dae93740d46c7c 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -320,6 +320,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)