This commit is contained in:
didier amyot committed 2023-12-15 13:35:54 -05:00
1 parent 9624918f12
commit ef879d8ec7
1 file changed
+22
View File
@@ -0,0 +1,22 @@
from pathlib import Path
def count_number_of_line(filename: str) -> int:
with open(filename, "rt") as file_:
return file_.read().count("\n")
def test_naive() -> None:
# setup
temp_file = Path("/tmp/test_toto")
temp_file.write_text("allo\nmon\ncoco\n")
assert count_number_of_line(temp_file) == 3
temp_file.unlink()
def test_with_basic_fixture(tmp_path: Path) -> None:
temp_file = tmp_path / "test_file"
temp_file.write_text("allo\nmon\ncoco\n")
assert count_number_of_line(temp_file) == 3