From 433028a39421983da971d70370cd9e93997f03ee Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 8 Apr 2022 18:29:45 -0400 Subject: [PATCH] Added unit tests for isEven --- test_main.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test_main.py diff --git a/test_main.py b/test_main.py new file mode 100644 index 0000000..e2ab4f9 --- /dev/null +++ b/test_main.py @@ -0,0 +1,30 @@ +from multiprocessing.spawn import old_main_modules +from main import isEven +import pytest + +# sudo apt install python3-pip +# pip3 install pytest --user +# pip3 install pytest-fixture --user + +# Autouse fixtures are meant for startup and teardown +# If you want the return value from a fixture, you must +# specify it in a parameter +@pytest.fixture(autouse=True) +def printWelcome(): + print("Starting tests!") + +@pytest.fixture() +def evenNumbers(): + return [2,4] + +@pytest.fixture +def oddNumbers(): + return [1,3] + +def test_isEven_even(evenNumbers): + for num in evenNumbers: + assert isEven(num); + +def test_isEven_odd(oddNumbers): + for num in oddNumbers: + assert not isEven(num);