2025-01-13 17:00:02 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2025-03-26 18:34:55 +01:00
|
|
|
import sys
|
2025-01-13 18:00:54 +01:00
|
|
|
import pytest
|
2025-01-13 17:00:02 +01:00
|
|
|
|
2025-03-26 18:34:55 +01:00
|
|
|
from wobbl_tools.text import Log
|
|
|
|
sys.path.append("..")
|
|
|
|
from utils import is_right # noqa
|
2025-01-13 17:00:02 +01:00
|
|
|
|
|
|
|
|
2025-03-26 18:34:55 +01:00
|
|
|
@pytest.mark.manual
|
|
|
|
def test_writing():
|
|
|
|
print("\n==== wobbl_tools.text.log =====")
|
2025-01-13 17:00:02 +01:00
|
|
|
|
2025-03-26 18:34:55 +01:00
|
|
|
log = Log("test_log.txt")
|
|
|
|
log.clear()
|
2025-01-13 17:00:02 +01:00
|
|
|
|
2025-03-26 18:34:55 +01:00
|
|
|
log.write("Testing the log module...")
|
|
|
|
log.write("This should be fine...", "ok")
|
|
|
|
log.write("Something happened...", "warning")
|
|
|
|
log.write("Oh shit!", "error")
|
2025-01-13 18:00:54 +01:00
|
|
|
|
2025-03-26 18:34:55 +01:00
|
|
|
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()
|