Skip to content
Snippets Groups Projects
Verified Commit 9dc59e23 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

test: give better error messages for `read_text`

parent 63871057
No related branches found
No related tags found
No related merge requests found
def test_read_text():
from src.enhanced_occurrence_frequencies import read_text
assert read_text("tests/sample.txt") == "this is a sample text file\n"
assert read_text("tests/empty.txt") == ""
assert read_text("tests/multiline.txt") == "i\nam\na\nmultiline\ntext\n"
assert read_text("tests/symbols.txt") == "this is a (sample) text, containing (a lot of) punctuation!!\n"
for (file, expected, msg) in [
("tests/sample.txt", "this is a sample text file\n", None),
(
"tests/empty.txt",
"",
"`read_text` should give an empty string for an empty file",
),
(
"tests/multiline.txt",
"i\nam\na\nmultiline\ntext\n",
"`read_text` should handle newlines",
),
(
"tests/symbols.txt",
"this is a (sample) text, containing (a lot of) punctuation!!\n",
"`read_text` should only make the text lower case, not remove symbols",
),
]:
if msg is not None:
assert read_text(file) == expected, msg
else:
assert read_text(file) == expected
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment