Add unittest for new text_helpers.
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 7 Oct 2016 14:22:59 +0000 (16:22 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 7 Oct 2016 14:22:59 +0000 (16:22 +0200)
Can only test whether functions raise an error since correct behaviour is
hard to test automatically.

test/test_text_helpers.py [new file with mode: 0644]

diff --git a/test/test_text_helpers.py b/test/test_text_helpers.py
new file mode 100644 (file)
index 0000000..5e9f2b6
--- /dev/null
@@ -0,0 +1,52 @@
+# The software in this package is distributed under the GNU General
+# Public License version 2 (with a special exception described below).
+#
+# A copy of GNU General Public License (GPL) is included in this distribution,
+# in the file COPYING.GPL.
+#
+# As a special exception, if other files instantiate templates or use macros
+# or inline functions from this file, or you compile this file and link it
+# with other works to produce a work based on this file, this file
+# does not by itself cause the resulting work to be covered
+# by the GNU General Public License.
+#
+# However the source code for this file must still be made available
+# in accordance with section (3) of the GNU General Public License.
+#
+# This exception does not invalidate any other reasons why a work based
+# on this file might be covered by the GNU General Public License.
+
+""" test_text_helpers.py: unit tests for text_helpers
+
+Tests classes and functions in text_helpers
+
+Should be able run from python2 and python3!
+
+For help see :py:mod:`unittest`
+
+.. codeauthor:: Intra2net
+"""
+
+from __future__ import print_function
+
+import unittest
+
+import text_helpers
+
+
+class TextHelpersTester(unittest.TestCase):
+    """
+    hard to test whether functions work correctly, can only check no raise
+    """
+
+    def test_shortcuts_do_not_raise(self):
+        """ tests all shortcut functions """
+        for color in COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, \
+                COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE:
+            exec('{0}("{0}")'.format(color))
+        for style in 'normal', 'bold', 'underline', 'blink', 'reverse':
+            exec('{0}("{0}")'.format(style))
+
+
+if __name__ == '__main__':
+    unittest.main()