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

Method test_tuple_subclass_with_auto_2

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

Source from the content-addressed store, hash-verified

2462 test_pickle_dump_load(self.assertIs, SomeEnum.first)
2463
2464 def test_tuple_subclass_with_auto_2(self):
2465 from collections import namedtuple
2466 T = namedtuple('T', 'index desc')
2467 class SomeEnum(Enum):
2468 __qualname__ = 'SomeEnum' # needed for pickle protocol 4
2469 first = T(auto(), 'for the money')
2470 second = T(auto(), 'for the show')
2471 third = T(auto(), 'for the music')
2472 self.assertIs(type(SomeEnum.first), SomeEnum)
2473 self.assertEqual(SomeEnum.third.value, (3, 'for the music'))
2474 self.assertIsInstance(SomeEnum.third.value, T)
2475 self.assertEqual(SomeEnum.first.value.index, 1)
2476 self.assertEqual(SomeEnum.second.value.desc, 'for the show')
2477 globals()['SomeEnum'] = SomeEnum
2478 globals()['T'] = T
2479 test_pickle_dump_load(self.assertIs, SomeEnum.first)
2480
2481 def test_duplicate_values_give_unique_enum_items(self):
2482 class AutoNumber(Enum):

Callers

nothing calls this directly

Calls 5

namedtupleFunction · 0.90
test_pickle_dump_loadFunction · 0.85
assertIsInstanceMethod · 0.80
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected