view tests/test_decorators.py @ 50:1284c99a94fa

stubbing
author Jeff Hammel <k0scist@gmail.com>
date Sat, 16 May 2015 21:02:07 -0700
parents ead4d5877b8f
children
line wrap: on
line source

#!/usr/bin/env python

import os
import unittest
from textshaper.decorator import lines

class TestDecorators(unittest.TestCase):
    """test decorator(s) for textshaper"""

    def test_lines(self):
        """test line decorator"""

        @lines
        def upper_case(text):
            return [line.upper() for line in text]

        content = """the quick brown fox
jumped over
the lazy dog"""

        _lines = content.splitlines()

        self.assertEqual(upper_case(content), """THE QUICK BROWN FOX
JUMPED OVER
THE LAZY DOG""")
        self.assertEqual(upper_case(_lines), ["THE QUICK BROWN FOX",
                                              "JUMPED OVER",
                                              "THE LAZY DOG"])

if __name__ == '__main__':
    unittest.main()