Skip to content

Commit

Permalink
Original test cases order kept
Browse files Browse the repository at this point in the history
1. Code formatting fixes via black
  • Loading branch information
sygutss committed Apr 22, 2022
1 parent aff29f9 commit 840af35
Showing 1 changed file with 41 additions and 44 deletions.
85 changes: 41 additions & 44 deletions testing/test_pytest_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,39 +1095,31 @@ def test_pass():
assert len(re.findall(collapsed_html, html)) == expected_count
assert_results(html, tests=2, passed=1, failed=1)

@pytest.mark.parametrize("keep_original_order, expected_table_header_tag", [
(
@pytest.mark.parametrize(
"keep_original_order, expected_table_header_tag",
[
(
False,
[
{
'html_tag': '<th class=".*sortable.*">',
'expected_count': 4
},
{
'html_tag': '<th class=".*initial-sort.*">',
'expected_count': 1
}
]
),
(
{"html_tag": '<th class=".*sortable.*">', "expected_count": 4},
{"html_tag": '<th class=".*initial-sort.*">', "expected_count": 1},
],
),
(
True,
[
{
'html_tag': '<th class=".*sortable.*">',
'expected_count': 0
},
{
'html_tag': '<th class=".*initial-sort.*">',
'expected_count': 0
}
]
)
], ids=(
"keep_original_order option is not set",
"keep_original_order option is set",
))
{"html_tag": '<th class=".*sortable.*">', "expected_count": 0},
{"html_tag": '<th class=".*initial-sort.*">', "expected_count": 0},
],
),
],
ids=(
"keep_original_order option is not set",
"keep_original_order option is set",
),
)
def test_keep_original_order_option_remove_any_sort_class_from_headers(
self, testdir, keep_original_order, expected_table_header_tag
self, testdir, keep_original_order, expected_table_header_tag
):
testdir.makeini(
f"""
Expand All @@ -1153,36 +1145,41 @@ def test_fail2():
result, html = run(testdir)
assert result.ret == 1
for expect_element in expected_table_header_tag:
assert len(
re.findall(expect_element["html_tag"], html)
) == expect_element["expected_count"]
assert (
len(re.findall(expect_element["html_tag"], html))
== expect_element["expected_count"]
)
assert_results(html, tests=4, passed=2, failed=2)

@pytest.mark.parametrize("keep_original_order, expected_order", [
(
@pytest.mark.parametrize(
"keep_original_order, expected_order",
[
(
False,
[
"test_fail1",
"test_fail2",
"test_pass1",
"test_pass2",
]
),
(
],
),
(
True,
[
"test_pass1",
"test_fail1",
"test_pass2",
"test_fail2",
]
)
], ids=(
"keep_original_order option is not set",
"keep_original_order option is set",
))
],
),
],
ids=(
"keep_original_order option is not set",
"keep_original_order option is set",
),
)
def test_keep_original_order_option_hold_test_run_order(
self, testdir, keep_original_order, expected_order
self, testdir, keep_original_order, expected_order
):
testdir.makeini(
f"""
Expand Down Expand Up @@ -1210,7 +1207,7 @@ def test_fail2():
result_report_test_order = re.findall('<td class="col-name">.*</td>', html)
assert len(result_report_test_order) == len(expected_order)
for expected_test_name, result_test_name in zip(
expected_order, result_report_test_order
expected_order, result_report_test_order
):
assert expected_test_name in result_test_name
assert_results(html, tests=4, passed=2, failed=2)
Expand Down

0 comments on commit 840af35

Please sign in to comment.