示例#1
0
 def test_to_short(self):
     with self.assertRaises(argparse.ArgumentTypeError):
         pattern.validator('')
     with self.assertRaises(argparse.ArgumentTypeError):
         pattern.validator('.e')
     with self.assertRaises(argparse.ArgumentTypeError):
         pattern.validator('.de')
示例#2
0
 def test_simple_valid(self):
     testcases = ['abc.de', 'LLL.de', 'L-L.de', 'DDDDDabcd.de', 'AA.de']
     for testcase in testcases:
         self.assertEqual(testcase, pattern.validator(testcase))
示例#3
0
 def test_tld_adding(self):
     self.assertEqual('AA.de', pattern.validator('AA'))
     self.assertEqual('abc.de', pattern.validator('abc'))
示例#4
0
 def test_dash_at_end(self):
     with self.assertRaises(argparse.ArgumentTypeError):
         pattern.validator('ajkf-.de')
     with self.assertRaises(argparse.ArgumentTypeError):
         pattern.validator('LDajd-')
示例#5
0
 def test_dash_at_beginning(self):
     with self.assertRaises(argparse.ArgumentTypeError):
         pattern.validator('-ajkf.de')
示例#6
0
 def test_invalid_chars(self):
     testcases = ['ab.c', 'L%LL.de', 'ħ""$%=($%.de']
     for testcase in testcases:
         with self.assertRaises(argparse.ArgumentTypeError):
             pattern.validator(testcase)