|
1 | 1 | from .. import stability
|
2 | 2 |
|
3 |
| - |
4 | 3 | def test_is_inconsistent():
|
5 | 4 | assert stability.is_inconsistent({"PASS": 10}, 10) is False
|
6 | 5 | assert stability.is_inconsistent({"PASS": 9}, 10) is True
|
@@ -29,3 +28,40 @@ def test_find_slow_status():
|
29 | 28 | "timeout": 100}) == "FAIL"
|
30 | 29 | assert stability.find_slow_status({
|
31 | 30 | "longest_duration": {"SKIP": 0}}) is None
|
| 31 | + |
| 32 | + |
| 33 | +def test_get_steps(): |
| 34 | + logger = None |
| 35 | + |
| 36 | + steps = stability.get_steps(logger, 0, 0, []) |
| 37 | + assert len(steps) == 0 |
| 38 | + |
| 39 | + steps = stability.get_steps(logger, 0, 0, [{}]) |
| 40 | + assert len(steps) == 0 |
| 41 | + |
| 42 | + repeat_loop = 1 |
| 43 | + flag_name = 'flag' |
| 44 | + flag_value = 'y' |
| 45 | + steps = stability.get_steps(logger, repeat_loop, 0, [ |
| 46 | + {flag_name: flag_value}]) |
| 47 | + assert len(steps) == 1 |
| 48 | + assert steps[0][0] == "Running tests in a loop %d times with flags %s=%s" % ( |
| 49 | + repeat_loop, flag_name, flag_value) |
| 50 | + |
| 51 | + repeat_loop = 0 |
| 52 | + repeat_restart = 1 |
| 53 | + flag_name = 'flag' |
| 54 | + flag_value = 'n' |
| 55 | + steps = stability.get_steps(logger, repeat_loop, repeat_restart, [ |
| 56 | + {flag_name: flag_value}]) |
| 57 | + assert len(steps) == 1 |
| 58 | + assert steps[0][0] == "Running tests in a loop with restarts %d times with flags %s=%s" % ( |
| 59 | + repeat_restart, flag_name, flag_value) |
| 60 | + |
| 61 | + repeat_loop = 10 |
| 62 | + repeat_restart = 5 |
| 63 | + steps = stability.get_steps(logger, repeat_loop, repeat_restart, [{}]) |
| 64 | + assert len(steps) == 2 |
| 65 | + assert steps[0][0] == "Running tests in a loop %d times" % repeat_loop |
| 66 | + assert steps[1][0] == ( |
| 67 | + "Running tests in a loop with restarts %d times" % repeat_restart) |
0 commit comments