예제 #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)