# HG changeset patch # User Sandro Knauß # Date 1329251227 -3600 # Node ID 2f9c439013b0904cc8c3fb40d1999d8898905c11 # Parent 497d6b9b6914a3ead35aaea41521e53ba3dbe1d9 renaming because of stadanrd module email in core python diff -r 497d6b9b6914 -r 2f9c439013b0 tests/email.py --- a/tests/email.py Tue Feb 14 21:24:31 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -import unittest - -from iro.validate import vEmail -from iro.error import InvalidMail - - -class testEmail(unittest.TestCase): - """tests for email adresses""" - - def testVaildEmail(self): - '''test vaild email adresses (got from wikipedia)''' - validmails=["niceandsimple@example.com", - "simplewith+symbol@example.com", - 'a.little.unusual@example.com', - 'a.little.more.unusual@dept.example.com', - '@[10.10.10.10]', - '@[1.1.1.1]', - '@[200.100.100.100]', - 'user@[2001:db8:1ff::a0b:dbd0]', - '"much.more\ unusual"@example.com', - 't."test".t@example.com', - '"very.unusual.@.unusual.com"@example.com', - '"very.(),:;<>[]\\".VERY.\\"very@\\\ \\"very\\".unusual"@strange.example.com', - "!#$%&'*+-/=?^_`{}|~@example.org", - '"()<>[]:;@,\\\"!#$%&\'*+-/=?^_`{}| ~ ? ^_`{}|~."@example.org', - '""@example.org'] - - for num in validmails: - self.failUnlessEqual(vEmail([num],None),[num]) - - def testInvaildEmail(self): - '''test invaild email adresses (got from wikipedia)''' - invalid=["Abc.example.com", # (an @ character must separate the local and domain parts) - "Abc.@example.com", # (character dot(.) is last in local part) - "Abc..123@example.com", # (character dot(.) is double) - "A@b@c@example.com", # (only one @ is allowed outside quotation marks) - 'a"b(c)d,e:f;gi[j\k]l@example.com', # (none of the special characters in this local part is allowed outside quotation marks) - 'just"not"right@example.com', # (quoted strings must be dot separated, or the only element making up the local-part) - 'thisis."notallowed@example.com', # (spaces, quotes, and backslashes may only exist when within quoted strings and preceded by a slash) - 'this\\ still\\"not\\allowed@example.com', # (even if escaped (preceded by a backslash), spaces, quotes, and backslashes must still be contained by quotes) - 't."test".t"test".t@example.com', - 't."test"t."test".t@example.com', - ] - - for number in invalid: - with self.assertRaises(InvalidMail) as e: - vEmail([number],None) - self.failUnlessEqual(e.exception.number, number) - - def testInvalidDomain(self): - '''invalid Domainname''' - with self.assertRaises(InvalidMail) as e: - vEmail(['x@&.de'],None) diff -r 497d6b9b6914 -r 2f9c439013b0 tests/email_validate.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/email_validate.py Tue Feb 14 21:27:07 2012 +0100 @@ -0,0 +1,53 @@ +import unittest + +from iro.validate import vEmail +from iro.error import InvalidMail + + +class testEmail(unittest.TestCase): + """tests for email adresses""" + + def testVaildEmail(self): + '''test vaild email adresses (got from wikipedia)''' + validmails=["niceandsimple@example.com", + "simplewith+symbol@example.com", + 'a.little.unusual@example.com', + 'a.little.more.unusual@dept.example.com', + '@[10.10.10.10]', + '@[1.1.1.1]', + '@[200.100.100.100]', + 'user@[2001:db8:1ff::a0b:dbd0]', + '"much.more\ unusual"@example.com', + 't."test".t@example.com', + '"very.unusual.@.unusual.com"@example.com', + '"very.(),:;<>[]\\".VERY.\\"very@\\\ \\"very\\".unusual"@strange.example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + '"()<>[]:;@,\\\"!#$%&\'*+-/=?^_`{}| ~ ? ^_`{}|~."@example.org', + '""@example.org'] + + for num in validmails: + self.failUnlessEqual(vEmail([num],None),[num]) + + def testInvaildEmail(self): + '''test invaild email adresses (got from wikipedia)''' + invalid=["Abc.example.com", # (an @ character must separate the local and domain parts) + "Abc.@example.com", # (character dot(.) is last in local part) + "Abc..123@example.com", # (character dot(.) is double) + "A@b@c@example.com", # (only one @ is allowed outside quotation marks) + 'a"b(c)d,e:f;gi[j\k]l@example.com', # (none of the special characters in this local part is allowed outside quotation marks) + 'just"not"right@example.com', # (quoted strings must be dot separated, or the only element making up the local-part) + 'thisis."notallowed@example.com', # (spaces, quotes, and backslashes may only exist when within quoted strings and preceded by a slash) + 'this\\ still\\"not\\allowed@example.com', # (even if escaped (preceded by a backslash), spaces, quotes, and backslashes must still be contained by quotes) + 't."test".t"test".t@example.com', + 't."test"t."test".t@example.com', + ] + + for number in invalid: + with self.assertRaises(InvalidMail) as e: + vEmail([number],None) + self.failUnlessEqual(e.exception.number, number) + + def testInvalidDomain(self): + '''invalid Domainname''' + with self.assertRaises(InvalidMail) as e: + vEmail(['x@&.de'],None)