25 lines
573 B
Python
25 lines
573 B
Python
from pathlib import Path
|
|
|
|
from strings_files import count_non_empty_lines, parse_key_value_lines
|
|
|
|
|
|
def test_parse_key_value_lines() -> None:
|
|
raw = """
|
|
# konfiguracja
|
|
HOST=127.0.0.1
|
|
PORT = 8080
|
|
|
|
DEBUG=true
|
|
"""
|
|
assert parse_key_value_lines(raw) == {
|
|
"HOST": "127.0.0.1",
|
|
"PORT": "8080",
|
|
"DEBUG": "true",
|
|
}
|
|
|
|
|
|
def test_count_non_empty_lines(tmp_path: Path) -> None:
|
|
sample = tmp_path / "sample.txt"
|
|
sample.write_text("line1\n\n \nline2\nline3\n", encoding="utf-8")
|
|
assert count_non_empty_lines(sample) == 3
|