Commit b1d6399d authored by Robert Behling's avatar Robert Behling
Browse files

unit tests

parent d1c228eb
......@@ -11,3 +11,8 @@ Python:pylint:
stage: test
- pipenv run pylint --rcfile test/linting/pylintrc src/*.py
stage: test
- pipenv run python -m unittest discover test/unittests
\ No newline at end of file
......@@ -91,6 +91,9 @@ def calculate_age(born: pd.Timestamp) -> int:
if not isinstance(born, pd.Timestamp):
raise TypeError
today =
return today.year - born.year - ((today.month, < (born.month,
import unittest # framework for testing
import pandas as pd
from src import astronaut_analysis # only works if calling the test from the root directory (cd) root directory is should be working directory
class TestCalculateAge(unittest.TestCase):
def test_return_type(self):
birth_date = pd.Timestamp('1950-01-01') # example data with correct type (set up of the test)
self.assertEqual(type(astronaut_analysis.calculate_age(birth_date)) ,int)
def test_arg_type(self):
birth_date = '1950-01-01' # example data with wrong data. set up which should fail
with self.assertRaises(TypeError):
### here we could test data types also for all other datatypes
# Main entry point
if __name__ == "__main__":
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment