示例#1
0
 def test_parse_bool(self):
     parser = defopt._get_parser(bool)
     self.assertEqual(parser('t'), True)
     self.assertEqual(parser('FALSE'), False)
     self.assertEqual(parser('1'), True)
     with self.assertRaises(ValueError):
         parser('foo')
示例#2
0
 def test_parse_slice(self):
     parser = defopt._get_parser(slice, {})
     self.assertEqual(parser(':'), slice(None))
     self.assertEqual(parser(':1'), slice(None, 1))
     self.assertEqual(parser('"a":"b":"c"'), slice("a", "b", "c"))
     with self.assertRaises(ValueError):
         parser('1')
示例#3
0
 def test_parse_bool(self):
     parser = defopt._get_parser(bool)
     self.assertEqual(parser('t'), True)
     self.assertEqual(parser('FALSE'), False)
     self.assertEqual(parser('1'), True)
     with self.assertRaises(ValueError):
         parser('foo')
示例#4
0
 def test_list_bare(self):
     with self.assertRaises(ValueError):
         defopt._get_parser(list)
示例#5
0
 def test_no_parser(self):
     with self.assertRaisesRegex(Exception, 'no parser'):
         defopt._get_parser(object, parsers={type: type})
示例#6
0
 def test_list_bare(self):
     with self.assertRaises(ValueError):
         defopt._get_parser(list)
示例#7
0
 def test_no_parser(self):
     with self.assertRaisesRegex(Exception, 'no parser'):
         defopt._get_parser(object)