-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathsubtest_as_step_test.py
More file actions
67 lines (57 loc) · 1.84 KB
/
subtest_as_step_test.py
File metadata and controls
67 lines (57 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import pytest
from hamcrest import assert_that
from tests.allure_pytest.pytest_runner import AllurePytestRunner
from allure_commons_test.report import has_test_case
from allure_commons_test.result import has_step
from allure_commons_test.result import with_status
from allure_commons_test.result import with_message_contains
from allure_commons_test.result import has_status_details
@pytest.mark.skipif("pytest.version_tuple[0] < 9")
def test_with_subtest(allure_pytest_runner: AllurePytestRunner):
"""
>>> import allure
>>> import pytest
>>> def test_with_subtest(subtests):
... with subtests.test(msg='Some failed subtest'):
... assert False, 'Some error'
... with allure.step('Next step'):
... pass
"""
allure_results = allure_pytest_runner.run_docstring()
assert_that(
allure_results,
has_test_case(
"test_with_subtest",
has_step(
"Some failed subtest",
with_status("failed"),
has_status_details(
with_message_contains("Some error")
)
),
has_step(
"Next step",
with_status("passed")
),
with_status("failed")
)
)
@pytest.mark.skipif("pytest.version_tuple[0] < 9")
def test_with_subtest_without_msg(allure_pytest_runner: AllurePytestRunner):
"""
>>> import allure
>>> import pytest
>>> def test_with_subtest_without_msg(subtests):
... with subtests.test():
... pass
"""
allure_results = allure_pytest_runner.run_docstring()
assert_that(
allure_results,
has_test_case(
"test_with_subtest_without_msg",
has_step(
"test_with_subtest_without_msg (<subtest>)",
),
)
)