Open GaelGil opened 5 years ago
Here's an example of a test you can write.
from app import clean_data
@pytest.mark.parametrize("uncleaned_data, cleaned_data", [
("the! man", ["the", "man"]),
("this; and He said:", ["this", "and", "he", "said"]),
("I looooove lasagna ;)", ["i", "looooove", "lasagna"]),
("I h8 lasagna ;)", ["i", "h", "lasagna"]),
("1 + 1 = 2", []),
])
def test_clean_data(uncleaned_data, cleaned_data):
assert clean_data(uncleaned_data)[0] == cleaned_data
Also, notice that this test:
clean_data
is wrong: def clean_data(data: list) -> list:
, but clearly the input is a str
"1 + 1 = 2"
gets mapped to []
(are you sure you want to do that?).
@pytest.mark.parametrize
and@pytest.fixture
are used to avoid repetition while writing test for exampleThis test uses
@pytest.mark.parametrize
and makes it more efficent to test more scenarios. What are some test I could try and write using@pytest.mark.parametrize
and@pytest.fixture
to stop some repetition.