|
3 | 3 |
|
4 | 4 | from easypy.timing import iter_wait, wait, repeat, iter_wait_progress, Timer, TimeoutException |
5 | 5 | from easypy.bunch import Bunch |
6 | | -from easypy.concurrency import concurrent |
7 | 6 |
|
8 | 7 |
|
9 | | -# Temporary tests for iter_wait() warnings |
10 | | -def test_wait_warning(): |
11 | | - with warnings.catch_warnings(record=True) as w: |
12 | | - warnings.simplefilter("always") |
| 8 | +def test_wait_exception(): |
| 9 | + with pytest.raises(Exception, match=".*`message` is required.*"): |
13 | 10 | wait(0.1, pred=lambda: True) |
14 | | - wait(0.1) |
15 | | - wait(0.1, pred=lambda: True, message='message') |
16 | | - wait(0.1, pred=lambda: True, message=False) |
17 | | - repeat(0.1, callback=lambda: True) |
18 | 11 |
|
19 | | - # Only the first call should throw a DeprecationWarning |
20 | | - assert len(w) == 1 |
21 | | - assert issubclass(w[-1].category, DeprecationWarning) |
22 | | - assert "wait()" in str(w[-1].message) |
| 12 | + wait(0.1) |
| 13 | + wait(0.1, pred=lambda: True, message='message') |
| 14 | + wait(0.1, pred=lambda: True, message=False) |
| 15 | + repeat(0.1, callback=lambda: True) |
23 | 16 |
|
24 | 17 |
|
25 | 18 | def test_iter_wait_warning(): |
26 | | - with warnings.catch_warnings(record=True) as w: |
27 | | - warnings.simplefilter("always") |
| 19 | + with pytest.raises(Exception, match=".*`message` is required.*"): |
28 | 20 | for _ in iter_wait(0.1, pred=lambda: True): |
29 | 21 | pass |
30 | 22 |
|
31 | | - no_warn_iters = [ |
32 | | - iter_wait(0.1), |
33 | | - iter_wait(0.1, pred=lambda: True, message='message'), |
34 | | - iter_wait(0.1, pred=lambda: True, throw=False), |
35 | | - iter_wait(0.1, pred=lambda: True, message=False) |
36 | | - ] |
37 | | - for i in no_warn_iters: |
38 | | - for _ in i: |
39 | | - pass |
40 | | - |
41 | | - # Only the first call should throw a DeprecationWarning |
42 | | - assert len(w) == 1 |
43 | | - assert issubclass(w[-1].category, DeprecationWarning) |
44 | | - assert "wait()" in str(w[-1].message) |
| 23 | + no_warn_iters = [ |
| 24 | + iter_wait(0.1), |
| 25 | + iter_wait(0.1, pred=lambda: True, message='message'), |
| 26 | + iter_wait(0.1, pred=lambda: True, throw=False), |
| 27 | + iter_wait(0.1, pred=lambda: True, message=False) |
| 28 | + ] |
| 29 | + for i in no_warn_iters: |
| 30 | + for _ in i: |
| 31 | + pass |
45 | 32 |
|
46 | 33 |
|
47 | 34 | def test_iter_wait_progress_inbetween_sleep(): |
@@ -96,7 +83,7 @@ def pred(): |
96 | 83 | finally: |
97 | 84 | wait(3) |
98 | 85 |
|
99 | | - wait(2, pred) |
| 86 | + wait(2, pred, message=False) |
100 | 87 |
|
101 | 88 |
|
102 | 89 | def test_wait_with_callable_message(): |
|
0 commit comments