tests: turn humantime test function into an unit test
This commit is contained in:
parent
21c8296d30
commit
a712de57bd
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from wcs.qommon.form import FileSizeWidget
|
||||
from wcs.qommon.humantime import humanduration2seconds, seconds2humanduration
|
||||
|
||||
def test_parse_file_size():
|
||||
assert FileSizeWidget.parse_file_size('17') == 17
|
||||
|
@ -19,3 +20,7 @@ def test_parse_invalid_file_size():
|
|||
for test_value in ('17i', 'hello', '0.4K', '2G'):
|
||||
with pytest.raises(ValueError):
|
||||
FileSizeWidget.parse_file_size(test_value)
|
||||
|
||||
def test_humantime():
|
||||
for x in range(3, 100000, 13):
|
||||
assert humanduration2seconds(seconds2humanduration(x)) == x
|
||||
|
|
|
@ -87,9 +87,3 @@ def seconds2humanduration(seconds):
|
|||
if seconds:
|
||||
human.append(_("%s seconds") % seconds)
|
||||
return list2human(human)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import random
|
||||
for x in range(1,10000):
|
||||
t = random.randint(1,100000)
|
||||
assert humanduration2seconds(seconds2humanduration(t))
|
||||
|
|
Loading…
Reference in New Issue