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

Method test_add_alias

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

Source from the content-addressed store, hash-verified

3449 self.assertEqual(list(MyEnum), [MyEnum.ID, MyEnum.NAME, MyEnum.ID_DESC, MyEnum.NAME_DESC])
3450
3451 def test_add_alias(self):
3452 class mixin:
3453 @property
3454 def ORG(self):
3455 return 'huh'
3456 class Color(mixin, Enum):
3457 RED = 1
3458 GREEN = 2
3459 BLUE = 3
3460 Color.RED._add_alias_('ROJO')
3461 self.assertIs(Color.RED, Color['ROJO'])
3462 self.assertIs(Color.RED, Color.ROJO)
3463 Color.BLUE._add_alias_('ORG')
3464 self.assertIs(Color.BLUE, Color['ORG'])
3465 self.assertIs(Color.BLUE, Color.ORG)
3466 self.assertEqual(Color.RED.ORG, 'huh')
3467 self.assertEqual(Color.GREEN.ORG, 'huh')
3468 self.assertEqual(Color.BLUE.ORG, 'huh')
3469 self.assertEqual(Color.ORG.ORG, 'huh')
3470
3471 def test_add_value_alias_after_creation(self):
3472 class Color(Enum):

Callers

nothing calls this directly

Calls 3

_add_alias_Method · 0.80
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected