MCPcopy Index your code
hub / github.com/python/cpython / test_extending

Method test_extending

Lib/test/test_enum.py:1902–1919  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1900 test_pickle_dump_load(self.assertIs, Name.BDFL)
1901
1902 def test_extending(self):
1903 class Color(Enum):
1904 red = 1
1905 green = 2
1906 blue = 3
1907 #
1908 with self.assertRaises(TypeError):
1909 class MoreColor(Color):
1910 cyan = 4
1911 magenta = 5
1912 yellow = 6
1913 #
1914 with self.assertRaisesRegex(TypeError, "<enum .EvenMoreColor.> cannot extend <enum .Color.>"):
1915 class EvenMoreColor(Color, IntEnum):
1916 chartruese = 7
1917 #
1918 with self.assertRaisesRegex(ValueError, r"\(.Foo., \(.pink., .black.\)\) is not a valid .*Color"):
1919 Color('Foo', ('pink', 'black'))
1920
1921 def test_exclude_methods(self):
1922 class whatever(Enum):

Callers

nothing calls this directly

Calls 3

assertRaisesRegexMethod · 0.80
ColorClass · 0.70
assertRaisesMethod · 0.45

Tested by

no test coverage detected