mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-116040: [Enum] fix test_empty_names test (GH-116508) (GH-116619)
* and fix _not_given usage
(cherry picked from commit 3c0dcef980
)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
This commit is contained in:
parent
1231697697
commit
8b3b5be934
2 changed files with 8 additions and 14 deletions
|
@ -3334,17 +3334,13 @@ class TestSpecial(unittest.TestCase):
|
|||
Flag(7)
|
||||
|
||||
def test_empty_names(self):
|
||||
for nothing, e_type in (
|
||||
('', None),
|
||||
('', int),
|
||||
([], None),
|
||||
([], int),
|
||||
({}, None),
|
||||
({}, int),
|
||||
):
|
||||
empty_enum = Enum('empty_enum', nothing, type=e_type)
|
||||
self.assertEqual(len(empty_enum), 0)
|
||||
self.assertRaises(TypeError, 'has no members', empty_enum, 0)
|
||||
for nothing in '', [], {}:
|
||||
for e_type in None, int:
|
||||
empty_enum = Enum('empty_enum', nothing, type=e_type)
|
||||
self.assertEqual(len(empty_enum), 0)
|
||||
self.assertRaisesRegex(TypeError, 'has no members', empty_enum, 0)
|
||||
self.assertRaisesRegex(TypeError, '.int. object is not iterable', Enum, 'bad_enum', names=0)
|
||||
self.assertRaisesRegex(TypeError, '.int. object is not iterable', Enum, 'bad_enum', 0, type=int)
|
||||
|
||||
|
||||
class TestOrder(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue