8000 Fix tests of the decorator exercise (#178) · fabioacl/python-tutorial@94ce66d · GitHub
[go: up one dir, main page]

Skip to content

Commit 94ce66d

Browse files
authored
Fix tests of the decorator exercise (empa-scientific-it#178)
1 parent 1b42590 commit 94ce66d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tutorial/tests/test_functions_advanced.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import pathlib
2+
import re
23
import time
34
import typing as t
5+
from math import isclose
46
from string import ascii_lowercase as lowercase
57
from string import ascii_uppercase as uppercase # noqa: F401
68
from string import digits, punctuation # noqa: F401
@@ -183,7 +185,10 @@ def test_once_twice(function_to_test: t.Callable) -> None:
183185
_hello("world 2")
184186

185187
assert err.type is RuntimeError
186-
assert "Wait another 5." in err.value.args[0]
188+
assert "Wait another" in err.value.args[0]
189+
190+
wait_time = re.search(r"[\d.]+", err.value.args[0])
191+
assert wait_time and isclose(float(wait_time.group()), 5.0, abs_tol=1e-2)
187192

188193

189194
def test_once_waiting_not_enough_time(function_to_test: t.Callable) -> None:
@@ -198,7 +203,10 @@ def test_once_waiting_not_enough_time(function_to_test: t.Callable) -> None:
198203
_hello("world 2")
199204

200205
assert err.type is RuntimeError
201-
assert "Wait another 1." in err.value.args[0]
206+
assert "Wait another" in err.value.args[0]
207+
208+
wait_time = re.search(r"[\d.]+", err.value.args[0])
209+
assert wait_time and isclose(float(wait_time.group()), 1.0, abs_tol=1e-2)
202210

203211

204212
#

0 commit comments

Comments
 (0)
0