Improved tests.
This commit is contained in:
parent
f2338cb337
commit
2082499c3d
4 changed files with 78 additions and 20 deletions
|
@ -1,15 +1,25 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import pytest
|
||||
|
||||
from wobbl_tools.text.format import format_string
|
||||
from wobbl_tools.text import format
|
||||
sys.path.append("..")
|
||||
from utils import is_right # noqa
|
||||
|
||||
print("\n==== wobbl_tools.text.format =====")
|
||||
|
||||
formats = list(format.color_ansi.keys())
|
||||
formats.remove("rs")
|
||||
formats.remove("reset")
|
||||
@pytest.mark.manual
|
||||
def test_formatting():
|
||||
print("\n==== wobbl_tools.text.format =====")
|
||||
|
||||
print("Is this shit looking right?\n")
|
||||
formats = list(format.color_ansi.keys())
|
||||
formats.remove("rs")
|
||||
formats.remove("reset")
|
||||
|
||||
for format_name in formats:
|
||||
print(f"{format_name.title().replace("_", " ")} text: {format_string(f"§{format_name}Text")}")
|
||||
print("Is this shit looking right?\n")
|
||||
|
||||
for format_name in formats:
|
||||
print(f"{format_name.title().replace('_', ' ')} text: {format_string(f'§{format_name}Text')}")
|
||||
|
||||
assert is_right()
|
||||
|
|
|
@ -1,22 +1,33 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import pytest
|
||||
from wobbl_tools.text.log import Log
|
||||
|
||||
print("\n==== wobbl_tools.text.log =====")
|
||||
from wobbl_tools.text import Log
|
||||
sys.path.append("..")
|
||||
from utils import is_right # noqa
|
||||
|
||||
test_log = Log("test_log.txt")
|
||||
test_log.clear()
|
||||
|
||||
test_log.write("Testing the log module...")
|
||||
test_log.write("This should be fine...", "ok")
|
||||
test_log.write("Something happened...", "warning")
|
||||
test_log.write("Oh shit!", "error")
|
||||
@pytest.mark.manual
|
||||
def test_writing():
|
||||
print("\n==== wobbl_tools.text.log =====")
|
||||
|
||||
print("Logfile contents:")
|
||||
print(test_log.read())
|
||||
log = Log("test_log.txt")
|
||||
log.clear()
|
||||
|
||||
without_file = Log()
|
||||
log.write("Testing the log module...")
|
||||
log.write("This should be fine...", "ok")
|
||||
log.write("Something happened...", "warning")
|
||||
log.write("Oh shit!", "error")
|
||||
|
||||
with pytest.raises(FileNotFoundError, match="You didn't specify a log path at the log instance definition."):
|
||||
without_file.read()
|
||||
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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue