From: Christian Herdtweck Date: Thu, 3 Dec 2015 15:23:30 +0000 (+0100) Subject: created test subdir with unit test template X-Git-Tag: v1.2~91 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=4ac72cfbd82606b0c771b4e5f79ccf9167cfa5b9;p=pyi2ncommon created test subdir with unit test template --- diff --git a/test/template.py b/test/template.py new file mode 100644 index 0000000..75f889f --- /dev/null +++ b/test/template.py @@ -0,0 +1,57 @@ +""" module_name_unittest.py: unit tests for module_name + +Tests classes and functions in module_name + +Should be run from python2 and python3! + +For help see :py:mod:`unittest` + +.. codeauthor:: your name, your.name@intra2net.com +""" + +import unittest + +import module_name + + +def setUpModule(): + """ called once before all tests in this module """ + print('setting up test module') + + +def tearDownModule(): + """ called once after all in this module are done """ + print('tearing down test module') + + +class ModuleNameTester(unittest.TestCase): + + @classmethod + def setUpClass(cls): + """ called once before tests in this class """ + print('setting up test class') + + @classmethod + def tearDownClass(cls): + """ called once when all tests in this class are done """ + print('tearing down test class') + + def setUp(self): + """ called before each test function """ + print('setup test') + + def tearDown(self): + """ called after each test function """ + print('tear down test') + + def test_some_func(self): + """ tests some_func """ + + this_is_implemented = False + self.assertTrue(this_is_implemented, 'Appears not yet implemented') + + self.fail('Fail in any case, but with this nice message') + + +if __name__ == '__main__': + unittest.main()