Exemplo n.º 1
0
 def test_make_identifiers(self):
     # Ensure that the make() interface also enforces identifiers.
     try:
         make('Foo', ('1', '2', '3'))
     except ValueError as exc:
         self.assertEqual(exc.args[0], 'non-identifiers: 1 2 3')
     else:
         raise AssertionError('Expected a ValueError')
     try:
         make('Foo', (('ant', 1), ('bee', 2), ('3', 'cat')))
     except ValueError as exc:
         self.assertEqual(exc.args[0], 'non-identifiers: 3')
     else:
         raise AssertionError('Expected a ValueError')
Exemplo n.º 2
0
 def test_make_identifiers(self):
     # Ensure that the make() interface also enforces identifiers.
     try:
         make('Foo', ('1', '2', '3'))
     except ValueError as exc:
         self.assertEqual(exc.args[0], 'non-identifiers: 1 2 3')
     else:
         raise AssertionError('Expected a ValueError')
     try:
         make('Foo', (('ant', 1), ('bee', 2), ('3', 'cat')))
     except ValueError as exc:
         self.assertEqual(exc.args[0], 'non-identifiers: 3')
     else:
         raise AssertionError('Expected a ValueError')
Exemplo n.º 3
0
 def test_deprecate_make(self):
     # LP: #1162375 -- use Enum() calling syntax instead.
     with warnings.catch_warnings(record=True) as seen:
         # In Python 3.3+ we can use self.assertWarns()
         warnings.simplefilter('always')
         Animals = make('Animals', 'ant bee cat'.split())
     self.assertEqual(len(seen), 1)
     self.assertEqual(seen[0].category, DeprecationWarning)
     # We don't need to assert the deprecation message.
     self.assertEqual(Animals.ant.value, 1)
Exemplo n.º 4
0
 def test_deprecate_make(self):
     # LP: #1162375 -- use Enum() calling syntax instead.
     with warnings.catch_warnings(record=True) as seen:
         # In Python 3.3+ we can use self.assertWarns()
         warnings.simplefilter('always')
         Animals = make('Animals', 'ant bee cat'.split())
     self.assertEqual(len(seen), 1)
     self.assertEqual(seen[0].category, DeprecationWarning)
     # We don't need to assert the deprecation message.
     self.assertEqual(Animals.ant.value, 1)