Publish workflow #2

Merged
mathias2784 merged 11 commits from publish-workflow into master 2026-10-01 19:31:35 +00:00
2 changed files with 34 additions and 0 deletions
Showing only changes of commit 5d34b8eeaf - Show all commits
+8
View File
@@ -0,0 +1,8 @@
def readlines(path: str) -> list[str]:
with open(path, "r") as fid:
lines = fid.readlines()
return lines
def read(path: str) -> str:
return "".join(readlines(path))
+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