diff options
Diffstat (limited to 'challenge-273/iangoodnight/python/tests')
| -rw-r--r-- | challenge-273/iangoodnight/python/tests/__init__.py | 7 | ||||
| -rw-r--r-- | challenge-273/iangoodnight/python/tests/test_task1.py | 22 | ||||
| -rw-r--r-- | challenge-273/iangoodnight/python/tests/test_task2.py | 10 |
3 files changed, 39 insertions, 0 deletions
diff --git a/challenge-273/iangoodnight/python/tests/__init__.py b/challenge-273/iangoodnight/python/tests/__init__.py new file mode 100644 index 0000000000..c06655e4a4 --- /dev/null +++ b/challenge-273/iangoodnight/python/tests/__init__.py @@ -0,0 +1,7 @@ +""" +Adds the parent directory to the path so that the modules can be imported from +our tests. +""" +import sys + +sys.path.append("..") diff --git a/challenge-273/iangoodnight/python/tests/test_task1.py b/challenge-273/iangoodnight/python/tests/test_task1.py new file mode 100644 index 0000000000..b27365fdac --- /dev/null +++ b/challenge-273/iangoodnight/python/tests/test_task1.py @@ -0,0 +1,22 @@ +"""Tests for task1.py""" +from python.task1 import percentage_of_character + + +def test_examples() -> None: + """Test if function returns correct percentage of character""" + assert percentage_of_character("perl", "e") == 25 + assert percentage_of_character("java", "a") == 50 + assert percentage_of_character("python", "m") == 0 + assert percentage_of_character("ada", "a") == 67 + assert percentage_of_character("ballerina", "l") == 22 + assert percentage_of_character("analitik", "k") == 13 + + +def test_empty_string() -> None: + """Test if function returns 0 for empty string""" + assert percentage_of_character("", "a") == 0 + + +def test_empty_character() -> None: + """Test if function returns 0 for empty character""" + assert percentage_of_character("python", "") == 0 diff --git a/challenge-273/iangoodnight/python/tests/test_task2.py b/challenge-273/iangoodnight/python/tests/test_task2.py new file mode 100644 index 0000000000..12dee45e22 --- /dev/null +++ b/challenge-273/iangoodnight/python/tests/test_task2.py @@ -0,0 +1,10 @@ +"""Tests for task2.py""" +from python.task2 import b_after_a + + +def test_examples() -> None: + """Test if function returns correct percentage of character""" + assert b_after_a("aabb") is True + assert b_after_a("abab") is False + assert b_after_a("aaa") is False + assert b_after_a("bbb") is True |
