wobbl_tools/tests/text/test_log.py
2025-03-26 18:34:55 +01:00

33 lines
719 B
Python

#!/usr/bin/python3
import sys
import pytest
from wobbl_tools.text import Log
sys.path.append("..")
from utils import is_right # noqa
@pytest.mark.manual
def test_writing():
print("\n==== wobbl_tools.text.log =====")
log = Log("test_log.txt")
log.clear()
log.write("Testing the log module...")
log.write("This should be fine...", "ok")
log.write("Something happened...", "warning")
log.write("Oh shit!", "error")
print("Logfile contents:")
print(log.read())
assert is_right()
def test_exception_without_file_on_read():
log = Log()
with pytest.raises(FileNotFoundError, match="You didn't specify a log path at the log instance definition."):
log.read()