From 214225a9a793c6d9a49089288de2c3b477fee393 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 21 Oct 2021 14:38:10 +0000 Subject: [PATCH 1/2] bpo-44019: Add test_all_exported_names for operator module --- Lib/test/test_operator.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index cf3439fe6fb82f..f4d8451038d0e1 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -45,6 +45,18 @@ def __iter__(self): class OperatorTestCase: + def test_all_exported_names(self): + operator = self.module + actual_all = set(operator.__all__) + computed_all = set() + for k in vars(operator): + if k.startswith('__'): + continue + value = getattr(operator, k) + if value.__module__ in ('operator', '_operator'): + computed_all.add(k) + self.assertSetEqual(computed_all, actual_all) + def test_lt(self): operator = self.module self.assertRaises(TypeError, operator.lt) From fa1c3d653ef4375652a94f6f138eb6b9b8008a67 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Fri, 22 Oct 2021 07:34:31 +0900 Subject: [PATCH 2/2] bpo-44019 Address Victor's code review --- Lib/test/test_operator.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index f4d8451038d0e1..b7e38c23349878 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -45,16 +45,16 @@ def __iter__(self): class OperatorTestCase: - def test_all_exported_names(self): + def test___all__(self): operator = self.module actual_all = set(operator.__all__) computed_all = set() - for k in vars(operator): - if k.startswith('__'): + for name in vars(operator): + if name.startswith('__'): continue - value = getattr(operator, k) + value = getattr(operator, name) if value.__module__ in ('operator', '_operator'): - computed_all.add(k) + computed_all.add(name) self.assertSetEqual(computed_all, actual_all) def test_lt(self):