From 87b420e21eebd7e23246f71e61acb92647765b49 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 2 Jan 2019 10:06:19 -0600 Subject: [PATCH] Attempting to integrate a basic test suite --- .gitlab-ci.yml | 14 ++++++++++++++ src/run_tests.py | 18 ++++++++++++++++++ src/test/test_setup_py2exe.py | 17 +++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/run_tests.py create mode 100644 src/test/test_setup_py2exe.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61f8cd5..736e678 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,20 @@ variables: PYINSTALLER: "C:\\python37\\scripts\\pyinstaller.exe" PYTHON2: "C:\\python27\\python.exe" +test_py3: + stage: test + tags: + - windows10 + before_script: + - '%PYTHON3% -V' + - '%PYTHON3% -m pip install --upgrade pip' + - '%PYTHON3% -m pip install --upgrade -r requirements.txt' + script: + - cd src + - '%PYTHON3% -m coverage run run_tests.py' + - '%PYTHON3% -m coverage report --omit="test*"' + coverage: '/TOTAL.+ ([0-9]{1,3}%)/' + alpha: type: deploy tags: diff --git a/src/run_tests.py b/src/run_tests.py new file mode 100644 index 0000000..c306566 --- /dev/null +++ b/src/run_tests.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +import unittest + +testmodules = ["test.test_renderers", "test.test_setup_py2exe"] + +suite = unittest.TestSuite() + +for t in testmodules: + try: + # If the module defines a suite() function, call it to get the suite. + mod = __import__(t, globals(), locals(), ['suite']) + suitefn = getattr(mod, 'suite') + suite.addTest(suitefn()) + except (ImportError, AttributeError): + # else, just load all the test cases from the module. + suite.addTest(unittest.defaultTestLoader.loadTestsFromName(t)) + +unittest.TextTestRunner(verbosity=2).run(suite) \ No newline at end of file diff --git a/src/test/test_setup_py2exe.py b/src/test/test_setup_py2exe.py new file mode 100644 index 0000000..762a1f9 --- /dev/null +++ b/src/test/test_setup_py2exe.py @@ -0,0 +1,17 @@ +import sys +import unittest +import application + +class py2exeTestCase(unittest.TestCase): + + @unittest.skipUnless(sys.version[0] == "2", "this only fails under Python 2") + def test_application_not_unicode(self): + """ Testing if some strings present in application have not changed to unicode. """ + self.assertIsInstance(application.name, str) + self.assertIsInstance(application.author, str) + self.assertIsInstance(application.authorEmail, str) + self.assertIsInstance(application.version, str) + self.assertIsInstance(application.url, str) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file