This commit is contained in:
2026-10-01 17:17:36 +02:00
parent 6696ff900e
commit 5d34b8eeaf
2 changed files with 34 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
from pathlib import Path
from utils.misc import read, readlines
CWD = Path(__file__).parent.resolve()
TEST_DATA_DIR = CWD / "data"
TEST_FILE_PATH = TEST_DATA_DIR / "text.txt"
EXPECTED_TEST = """This is a test file
with a second line
and a third line
"""
def test_readlines_str():
result = readlines(TEST_FILE_PATH)
assert result
assert isinstance(result, list)
assert all(isinstance(element, str) for element in result)
assert result[1].strip() == "with a second line"
def test_path_str():
result = read(TEST_FILE_PATH)
assert result
assert isinstance(result, str)
assert result == EXPECTED_TEST