diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98ff46b54f845720bf8d4030373eca9eccd53c02..7979b817a0b2f75b858f59a60360f56d143429f9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,7 @@ linting: stage: test script: - flake8 --ignore=F403,F405,F821,F841,W504 fixhdr + - flake8 tests python3.6: image: python:3.6 diff --git a/tests/test_fixhdr.py b/tests/test_fixhdr.py index 7520eb40c343bc59a0ac890a78a20f830777b7d2..dbe9358706774f9e2d6da6c7bafe1bd888cbee18 100644 --- a/tests/test_fixhdr.py +++ b/tests/test_fixhdr.py @@ -4,21 +4,22 @@ """Tests for `fixhdr` package.""" import unittest -import sys -try: - import fixhdr -except ImportError: - pass +from unittest.mock import patch + class TestFixhdr(unittest.TestCase): """Tests for `fixhdr` package.""" - def setUp(self): - """Set up test fixtures, if any.""" - - def tearDown(self): - """Tear down test fixtures, if any.""" - def test_import(self): - self.assertTrue('fixhdr' in sys.modules, "Fixhdr import failed!") + """Test fixhdr import""" + with patch("sys.argv", ["fixhdr", "-#"]): + with self.assertRaises(SystemExit) as cmd: + try: + import fixhdr.fixhdr as fx + fx.Usage() + except ImportError as e: + print(e) + self.fail("fixhdr import failed") + self.assertEqual(cmd.exception.code, 0, "sys.exit(0) never called " + "- Failed to exercise fixhdr") diff --git a/tox.ini b/tox.ini index dfe02e14a70ba8c17d832fd98e09ce2bc0fdb691..8ad663cc6745ae0af255931d48917be7805ecf83 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ envlist = py36, py37, py38, flake8 basepython = python deps = flake8 commands = flake8 --ignore=F403,F405,F821,F841,W504 fixhdr + flake8 tests [testenv] commands = python -m unittest