Adjust check_int_positive tests

This commit is contained in:
Matthias 2019-05-25 13:16:00 +02:00
parent 7bbe8b2483
commit 469c0b6a55
2 changed files with 10 additions and 6 deletions

View File

@ -405,7 +405,7 @@ class Arguments(object):
raise Exception('Incorrect syntax for timerange "%s"' % text)
@staticmethod
def check_int_positive(value) -> int:
def check_int_positive(value: str) -> int:
try:
uint = int(value)
if uint <= 0:

View File

@ -187,13 +187,17 @@ def test_testdata_dl_options() -> None:
def test_check_int_positive() -> None:
assert Arguments.check_int_positive(2) == 2
assert Arguments.check_int_positive(6) == 6
with pytest.raises(argparse.ArgumentTypeError):
Arguments.check_int_positive(-6)
assert Arguments.check_int_positive(2.5) == 2
assert Arguments.check_int_positive("3") == 3
assert Arguments.check_int_positive("1") == 1
assert Arguments.check_int_positive("100") == 100
with pytest.raises(argparse.ArgumentTypeError):
Arguments.check_int_positive("-2")
with pytest.raises(argparse.ArgumentTypeError):
Arguments.check_int_positive("0")
with pytest.raises(argparse.ArgumentTypeError):
Arguments.check_int_positive("3.5")