Skip to content

gh-109774: Remove duplicated tests from test_enum #109775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,14 @@ 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'

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)
Expand Down Expand Up @@ -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
#
Expand All @@ -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)
Expand All @@ -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')
Expand All @@ -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

Expand Down