Sample Solution
The following shows one way to solve this problem. It is not the only way this problem can be solved.
check_solution.py
# Copyright 2020, Brigham Young University-Idaho. All rights reserved.
"""Verify that the prefix and suffix functions work correctly."""
from words import prefix, suffix
import pytest
def test_prefix():
"""Verify that the prefix function works correctly.
Parameters: none
Return: nothing
"""
assert prefix("", "") == ""
assert prefix("", "correct") == ""
assert prefix("clear", "") == ""
assert prefix("happy", "funny") == ""
assert prefix("cat", "catalog") == "cat"
assert prefix("dogmatic", "dog") == "dog"
assert prefix("jump", "joyous") == "j"
assert prefix("unwise", "ungrateful") == "un"
assert prefix("Disable", "dIstasteful") == "dis"
def test_suffix():
"""Verify that the suffix function works correctly.
Parameters: none
Return: nothing
"""
assert suffix("", "") == ""
assert suffix("", "correct") == ""
assert suffix("clear", "") == ""
assert suffix("angelic", "awesome") == ""
assert suffix("found", "profound") == "found"
assert suffix("ditch", "itch") == "itch"
assert suffix("happy", "funny") == "y"
assert suffix("tired", "fatigued") == "ed"
assert suffix("swimming", "FLYING") == "ing"
# Call the main function that is part of pytest so that
# the test functions in this file will start executing.
pytest.main(["-v", "--tb=line", "-rN", __file__])
# Copyright 2020, Brigham Young University-Idaho. All rights reserved.
"""Verify that the prefix and suffix functions work correctly."""
from words import prefix, suffix
import pytest
def test_prefix():
"""Verify that the prefix function works correctly.
Parameters: none
Return: nothing
"""
assert prefix("", "") == ""
assert prefix("", "correct") == ""
assert prefix("clear", "") == ""
assert prefix("happy", "funny") == ""
assert prefix("cat", "catalog") == "cat"
assert prefix("dogmatic", "dog") == "dog"
assert prefix("jump", "joyous") == "j"
assert prefix("unwise", "ungrateful") == "un"
assert prefix("Disable", "dIstasteful") == "dis"
def test_suffix():
"""Verify that the suffix function works correctly.
Parameters: none
Return: nothing
"""
assert suffix("", "") == ""
assert suffix("", "correct") == ""
assert suffix("clear", "") == ""
assert suffix("angelic", "awesome") == ""
assert suffix("found", "profound") == "found"
assert suffix("ditch", "itch") == "itch"
assert suffix("happy", "funny") == "y"
assert suffix("tired", "fatigued") == "ed"
assert suffix("swimming", "FLYING") == "ing"
# Call the main function that is part of pytest so that
# the test functions in this file will start executing.
pytest.main(["-v", "--tb=line", "-rN", __file__])
Download: check_solution.py