File utils1 (#1)
Tests / test_and_lint (push) Successful in 7s

Reviewed-on: #1
Co-authored-by: Mathias Scheider <mathias2784@web.de>
This commit was merged in pull request #1.
This commit is contained in:
2026-10-01 19:13:45 +00:00
committed by mathias2784
parent 59faa596d5
commit 9d13c6ec14
12 changed files with 452 additions and 15 deletions
+27
View File
@@ -0,0 +1,27 @@
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