From c14740b2a68f86bffbac7bc009273f69353d59e7 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Tue, 22 May 2018 12:09:07 +0200 Subject: [PATCH] Move template for tests to template dir --- templates/test_template.py | 80 ++++++++++++++++++++++++++++++++++++++++++++ test/template.py | 80 -------------------------------------------- 2 files changed, 80 insertions(+), 80 deletions(-) create mode 100644 templates/test_template.py delete mode 100644 test/template.py diff --git a/templates/test_template.py b/templates/test_template.py new file mode 100644 index 0000000..fb85c91 --- /dev/null +++ b/templates/test_template.py @@ -0,0 +1,80 @@ +# 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_module_name.py: unit tests for module_name + +Tests classes and functions in module_name + +Should be able run from python2 and python3! + +For help see :py:mod:`unittest` + +.. codeauthor:: Intra2net +""" + +from __future__ import print_function +from __future__ import absolute_import + +import unittest + +# relative import of tested module ensures we do not test installed version +from src 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): + """ only test case in this module, see module doc for more help """ + + @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() diff --git a/test/template.py b/test/template.py deleted file mode 100644 index fb85c91..0000000 --- a/test/template.py +++ /dev/null @@ -1,80 +0,0 @@ -# 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_module_name.py: unit tests for module_name - -Tests classes and functions in module_name - -Should be able run from python2 and python3! - -For help see :py:mod:`unittest` - -.. codeauthor:: Intra2net -""" - -from __future__ import print_function -from __future__ import absolute_import - -import unittest - -# relative import of tested module ensures we do not test installed version -from src 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): - """ only test case in this module, see module doc for more help """ - - @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() -- 1.7.1