From 2e5c5b849277abb0c450b3e433aa5c35377e5c8e Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Fri, 7 Oct 2016 16:22:59 +0200 Subject: [PATCH] Add unittest for new text_helpers. Can only test whether functions raise an error since correct behaviour is hard to test automatically. --- test/test_text_helpers.py | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) create mode 100644 test/test_text_helpers.py diff --git a/test/test_text_helpers.py b/test/test_text_helpers.py new file mode 100644 index 0000000..5e9f2b6 --- /dev/null +++ b/test/test_text_helpers.py @@ -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() -- 1.7.1