Пример #1
0
 def test_iterable(self):
     globalns = {'typing': typing}
     type_ = defopt._get_type_from_doc('typing.Iterable[int]', globalns)
     self.assertEqual(type_.container, list)
     self.assertEqual(type_.type, int)
Пример #2
0
 def test_other(self):
     with self.assertRaisesRegexp(ValueError, 'unsupported.*tuple'):
         defopt._get_type_from_doc('tuple[int]', {})
Пример #3
0
 def test_sequence(self):
     globalns = {'Sequence': typing.Sequence}
     type_ = defopt._get_type_from_doc('Sequence[int]', globalns)
     self.assertEqual(type_.container, list)
     self.assertEqual(type_.type, int)