5 class UrinormTest(unittest
.TestCase
):
6 def __init__(self
, desc
, case
, expected
):
7 unittest
.TestCase
.__init
__(self
)
10 self
.expected
= expected
12 def shortDescription(self
):
17 actual
= openid
.urinorm
.urinorm(self
.case
)
18 except ValueError, why
:
19 self
.assertEqual(self
.expected
, 'fail', why
)
21 self
.assertEqual(actual
, self
.expected
)
23 def parse(cls
, full_case
):
24 desc
, case
, expected
= full_case
.split('\n')
25 case
= unicode(case
, 'utf-8')
27 return cls(desc
, case
, expected
)
29 parse
= classmethod(parse
)
32 def parseTests(test_data
):
35 cases
= test_data
.split('\n\n')
40 result
.append(UrinormTest
.parse(case
))
45 here
= os
.path
.dirname(os
.path
.abspath(__file__
))
46 test_data_file_name
= os
.path
.join(here
, 'urinorm.txt')
47 test_data_file
= file(test_data_file_name
)
48 test_data
= test_data_file
.read()
49 test_data_file
.close()
51 tests
= parseTests(test_data
)
52 return unittest
.TestSuite(tests
)