forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_generate.py
More file actions
30 lines (25 loc) · 1.14 KB
/
test_generate.py
File metadata and controls
30 lines (25 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import unittest, doctest
import pyzmail
from pyzmail.generate import *
class TestGenerate(unittest.TestCase):
def setUp(self):
pass
def test_format_addresses(self):
"""test format_addresse"""
self.assertEqual('foo@example.com', str(format_addresses([ 'foo@example.com', ])))
self.assertEqual('Foo <foo@example.com>', str(format_addresses([ ('Foo', 'foo@example.com'), ])))
# notice the space around the comma
self.assertEqual('foo@example.com , bar@example.com', str(format_addresses([ 'foo@example.com', 'bar@example.com'])))
# notice the space around the comma
self.assertEqual('Foo <foo@example.com> , Bar <bar@example.com>', str(format_addresses([ ('Foo', 'foo@example.com'), ( 'Bar', 'bar@example.com')])))
# Add doctest
def load_tests(loader, tests, ignore):
# this works with python 2.7 and 3.x
tests.addTests(doctest.DocTestSuite(pyzmail.generate))
return tests
def additional_tests():
# Add doctest for python 2.6 and below
if sys.version_info<(2, 7):
return doctest.DocTestSuite(pyzmail.generate)
else:
return unittest.TestSuite()