30
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import os
|
|
4 import unittest
|
|
5 from textshaper.decorator import lines
|
|
6
|
|
7 class TestDecorators(unittest.TestCase):
|
|
8 """test decorator(s) for textshaper"""
|
|
9
|
|
10 def test_lines(self):
|
|
11 """test line decorator"""
|
|
12
|
|
13 @lines
|
|
14 def upper_case(text):
|
|
15 return [line.upper() for line in text]
|
|
16
|
|
17 content = """the quick brown fox
|
|
18 jumped over
|
|
19 the lazy dog"""
|
|
20
|
|
21 _lines = content.splitlines()
|
|
22
|
|
23 self.assertEqual(upper_case(content), """THE QUICK BROWN FOX
|
|
24 JUMPED OVER
|
|
25 THE LAZY DOG""")
|
|
26 self.assertEqual(upper_case(_lines), ["THE QUICK BROWN FOX",
|
|
27 "JUMPED OVER",
|
|
28 "THE LAZY DOG"])
|
|
29
|
|
30 if __name__ == '__main__':
|
|
31 unittest.main()
|