Skip to content

Commit 6feb194

Browse files
authored
Unit test for get_steps (web-platform-tests#22536)
Unit tests for the get_steps() function in stability.py covering all the branches. It increases the unit tests code coverage support by 6%.
1 parent 3637298 commit 6feb194

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

tools/wptrunner/wptrunner/tests/test_stability.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .. import stability
22

3-
43
def test_is_inconsistent():
54
assert stability.is_inconsistent({"PASS": 10}, 10) is False
65
assert stability.is_inconsistent({"PASS": 9}, 10) is True
@@ -29,3 +28,40 @@ def test_find_slow_status():
2928
"timeout": 100}) == "FAIL"
3029
assert stability.find_slow_status({
3130
"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

Comments
 (0)