From 0c579a4821cdd0d064b72aa410ae49991fbf065b Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 21 Oct 2022 13:02:24 +0300 Subject: [PATCH] gh-98512: Add more tests for `ValuesView` and `KeysView` --- 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 1e398d6c3c7a3f..35ba5e97528b84 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 7c48d800cd88bd..924f4a6829e19c 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)