Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- from email import *
- class EmailTests(unittest.TestCase):
- def test_rule_1(self):
- cases = (
- ("abcvsio", RULE_1_ERROR),
- ("aovooioaisd@mail.ru", CHECK_OK),
- )
- for case in cases:
- r = check_email(case[0])
- try:
- self.assertEqual(r, case[1])
- except AssertionError:
- print case[0], r, case[1]
- raise AssertionError
- def test_rule_2(self):
- cases = (
- ("abcdef@y.r", RULE_2_ERROR_1),
- ("abcdef@yandex.ru", CHECK_OK),
- ("abcdef@{}.ru".format("y" * 300), RULE_2_ERROR_1),
- )
- for case in cases:
- r = check_email(case[0])
- try:
- self.assertEqual(r, case[1])
- except AssertionError:
- print case[0], r, case[1]
- raise AssertionError
- def test_rule_3(self):
- cases = (
- ("abcdef@-yandex.ru", RULE_3_ERROR),
- ("abcdef@-yandex-.ru", RULE_3_ERROR),
- ("abcdef@yandex-.ru", RULE_3_ERROR),
- ("abcdef@yandex.ru", CHECK_OK),
- )
- for case in cases:
- r = check_email(case[0])
- try:
- self.assertEqual(r, case[1])
- except AssertionError:
- print case[0], r, case[1]
- raise AssertionError
- def test_rule_4(self):
- cases = (
- ("abc.def{}@yandex.ru".format("ddd" * 128), RULE_4_ERROR_1),
- ("abc-def@yandex.ru", CHECK_OK),
- ("abc1234465787999@yandex.ru", CHECK_OK),
- )
- for case in cases:
- r = check_email(case[0])
- try:
- self.assertEqual(r, case[1])
- except AssertionError:
- print case[0], r, case[1]
- raise AssertionError
- def test_rule_5(self):
- cases = (
- ("abc.def@yandex.ru", CHECK_OK),
- ("abc..def@yandex.ru", RULE_5_ERROR),
- )
- for case in cases:
- r = check_email(case[0])
- try:
- self.assertEqual(r, case[1])
- except AssertionError:
- print case[0], r, case[1]
- raise AssertionError
- def test_rule_6(self):
- cases = (
- ("abcdef@yandex.ru", CHECK_OK),
- ("ab\"cdef@yandex.ru", RULE_6_ERROR),
- ("a\"bc\"def@yandex.ru", CHECK_OK),
- ("a\"bc\"def\"vvv\"@yandex.ru", CHECK_OK),
- ("a\"bc\"de\"f@yandex.ru", RULE_6_ERROR),
- )
- for case in cases:
- r = check_email(case[0])
- try:
- self.assertEqual(r, case[1])
- except AssertionError:
- print case[0], r, case[1]
- raise AssertionError
- def test_rule_7(self):
- cases = (
- ("abcdef@yandex.ru", CHECK_OK),
- ("a\"bbb!\"def@yandex.ru", CHECK_OK),
- ("a\"ccc,;\"def@yandex.ru", RULE_4_ERROR_2),
- ("a\"eee:e\"def@yandex.ru", CHECK_OK),
- ("a,:vvv\"@yandex.ru", RULE_7_ERROR),
- ("a!poaf@yandex.ru", RULE_7_ERROR),
- )
- for case in cases:
- r = check_email(case[0])
- try:
- self.assertEqual(r, case[1])
- except AssertionError:
- print case[0], r, case[1]
- raise AssertionError
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement