From 2a020371bbc01af0f09cf32e22321c23951c2a24 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 23 Sep 2023 09:28:35 +0300 Subject: [PATCH] gh-109774: Remove duplicated tests from `test_enum` --- Lib/test/test_enum.py | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index 8c1f285f7b3bc2..27f69b1c40e707 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -497,7 +497,6 @@ class Empty(self.enum_type): self.assertTrue(member) def test_changing_member_fails(self): - MainEnum = self.MainEnum with self.assertRaises(AttributeError): self.MainEnum.second = 'really first' @@ -505,7 +504,7 @@ def test_contains_tf(self): MainEnum = self.MainEnum self.assertIn(MainEnum.first, MainEnum) self.assertTrue(self.values[0] in MainEnum) - if type(self) not in (TestStrEnumClass, TestStrEnumFunction): + if type(self) is not TestStrEnumClass: self.assertFalse('first' in MainEnum) val = MainEnum.dupe self.assertIn(val, MainEnum) @@ -1035,18 +1034,10 @@ class TestPlainEnumClass(_EnumTests, _PlainOutputTests, unittest.TestCase): enum_type = Enum -class TestPlainEnumFunction(_EnumTests, _PlainOutputTests, unittest.TestCase): - enum_type = Enum - - class TestPlainFlagClass(_EnumTests, _PlainOutputTests, _FlagTests, unittest.TestCase): enum_type = Flag -class TestPlainFlagFunction(_EnumTests, _PlainOutputTests, _FlagTests, unittest.TestCase): - enum_type = Flag - - class TestIntEnumClass(_EnumTests, _MinimalOutputTests, unittest.TestCase): enum_type = IntEnum # @@ -1057,12 +1048,8 @@ class Number(IntEnum): # self.assertEqual(Number.divisor.numerator, 1) self.assertIs(Number.numerator.divisor, Number.divisor) - - -class TestIntEnumFunction(_EnumTests, _MinimalOutputTests, unittest.TestCase): - enum_type = IntEnum # - def test_shadowed_attr(self): + def test_shadowed_attr_func(self): Number = IntEnum('Number', ('divisor', 'numerator')) # self.assertEqual(Number.divisor.numerator, 1) @@ -1080,12 +1067,8 @@ class Book(StrEnum): self.assertEqual(Book.author.title(), 'Author') self.assertEqual(Book.title.title(), 'Title') self.assertIs(Book.title.author, Book.author) - - -class TestStrEnumFunction(_EnumTests, _MinimalOutputTests, unittest.TestCase): - enum_type = StrEnum # - def test_shadowed_attr(self): + def test_shadowed_attr_func(self): Book = StrEnum('Book', ('author', 'title')) # self.assertEqual(Book.author.title(), 'Author') @@ -1097,10 +1080,6 @@ class TestIntFlagClass(_EnumTests, _MinimalOutputTests, _FlagTests, unittest.Tes enum_type = IntFlag -class TestIntFlagFunction(_EnumTests, _MinimalOutputTests, _FlagTests, unittest.TestCase): - enum_type = IntFlag - - class TestMixedIntClass(_EnumTests, _MixedOutputTests, unittest.TestCase): class enum_type(int, Enum): pass