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')
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))
def test_tld_adding(self): self.assertEqual('AA.de', pattern.validator('AA')) self.assertEqual('abc.de', pattern.validator('abc'))
def test_dash_at_end(self): with self.assertRaises(argparse.ArgumentTypeError): pattern.validator('ajkf-.de') with self.assertRaises(argparse.ArgumentTypeError): pattern.validator('LDajd-')
def test_dash_at_beginning(self): with self.assertRaises(argparse.ArgumentTypeError): pattern.validator('-ajkf.de')
def test_invalid_chars(self): testcases = ['ab.c', 'L%LL.de', 'ħ""$%=($%.de'] for testcase in testcases: with self.assertRaises(argparse.ArgumentTypeError): pattern.validator(testcase)