Skip to content
Snippets Groups Projects
Commit f3c06d00 authored by Maeva Pourpoint's avatar Maeva Pourpoint
Browse files

Add unit tests to ensure code basic functionalities

parent d52a16a4
No related branches found
No related tags found
1 merge request!6Unit tests
Pipeline #900 passed with stage
in 40 seconds
...@@ -27,6 +27,7 @@ linting: ...@@ -27,6 +27,7 @@ linting:
stage: test stage: test
script: script:
- flake8 --ignore=F403,F405,F821,F841,W504 fixhdr - flake8 --ignore=F403,F405,F821,F841,W504 fixhdr
- flake8 tests
python3.6: python3.6:
image: python:3.6 image: python:3.6
......
...@@ -4,21 +4,22 @@ ...@@ -4,21 +4,22 @@
"""Tests for `fixhdr` package.""" """Tests for `fixhdr` package."""
import unittest import unittest
import sys
try: from unittest.mock import patch
import fixhdr
except ImportError:
pass
class TestFixhdr(unittest.TestCase): class TestFixhdr(unittest.TestCase):
"""Tests for `fixhdr` package.""" """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): 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")
...@@ -5,6 +5,7 @@ envlist = py36, py37, py38, flake8 ...@@ -5,6 +5,7 @@ envlist = py36, py37, py38, flake8
basepython = python basepython = python
deps = flake8 deps = flake8
commands = flake8 --ignore=F403,F405,F821,F841,W504 fixhdr commands = flake8 --ignore=F403,F405,F821,F841,W504 fixhdr
flake8 tests
[testenv] [testenv]
commands = python -m unittest commands = python -m unittest
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment