Typing: Options

This commit is contained in:
Thomas Holder
2023-12-13 15:18:39 +01:00
parent 723609cc33
commit 0aafca7f73
10 changed files with 184 additions and 92 deletions

27
tests/test_lib.py Normal file
View File

@@ -0,0 +1,27 @@
import propka.lib as m
import argparse
import pytest
def test_parse_res_string():
assert m.parse_res_string("C:123") == ("C", 123, " ")
assert m.parse_res_string("C:123B") == ("C", 123, "B")
assert m.parse_res_string("ABC:123x") == ("ABC", 123, "x")
with pytest.raises(ValueError):
m.parse_res_string("C:B123")
with pytest.raises(ValueError):
m.parse_res_string("123B")
with pytest.raises(ValueError):
m.parse_res_string("C:123:B")
def test_parse_res_list():
assert m.parse_res_list("C:123") == [("C", 123, " ")]
assert m.parse_res_list("ABC:123,D:4,F:56X") == [
("ABC", 123, " "),
("D", 4, " "),
("F", 56, "X"),
]
with pytest.raises(argparse.ArgumentTypeError):
m.parse_res_list("C:B123")