-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix suite label duplication when using dynamic suite functions (Fixes #…
- Loading branch information
Showing
3 changed files
with
89 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
Custom suite | ||
____________ | ||
|
||
Use the `@allure.parent_suite`, `@allure.suite`, or `@allure.sub_suite` | ||
decorators to overwrite default suite labels: | ||
|
||
>>> import allure | ||
|
||
>>> @allure.parent_suite("parent suite name") | ||
>>> @allure.suite("suite name") | ||
>>> @allure.sub_suite("sub suite name") | ||
... def test_custom_suite(): | ||
... pass | ||
>>> class TestCustomSuites: | ||
... @allure.parent_suite("parent suite name") | ||
... @allure.suite("suite name") | ||
... @allure.sub_suite("sub suite name") | ||
... def test_custom_suites(self): | ||
... pass | ||
|
||
|
||
Use the `allure.dynamic.parent_suite`, `allure.dynamic.suite`, or | ||
`allure.dynamic.sub_suite` functions to overwrite default suite labels | ||
dynamically: | ||
|
||
>>> import allure | ||
|
||
>>> class TestCustomDynamicSuites: | ||
... def test_custom_dynamic_suites(self): | ||
... allure.dynamic.parent_suite("parent suite name") | ||
... allure.dynamic.suite("suite name") | ||
... allure.dynamic.sub_suite("sub suite name") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 50 additions & 4 deletions
54
tests/allure_pytest/acceptance/label/suite/custom_suite_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
""" ./allure-pytest/examples/label/suite/custom_suite.rst """ | ||
|
||
from hamcrest import assert_that | ||
from hamcrest import assert_that, not_ | ||
from tests.allure_pytest.pytest_runner import AllurePytestRunner | ||
|
||
import allure | ||
from allure_commons_test.report import has_test_case | ||
from allure_commons_test.label import has_suite, has_parent_suite, has_sub_suite | ||
|
||
|
||
def test_custom_suite(allure_pytest_runner: AllurePytestRunner): | ||
allure_results = allure_pytest_runner.run_docpath_examples() | ||
allure_results = allure_pytest_runner.run_docpath_examples(cache=True) | ||
|
||
assert_that( | ||
allure_results, | ||
has_test_case( | ||
"test_custom_suite", | ||
"TestCustomSuites#test_custom_suites", | ||
has_suite("suite name"), | ||
has_parent_suite("parent suite name"), | ||
has_sub_suite("sub suite name") | ||
has_sub_suite("sub suite name"), | ||
not_( | ||
has_parent_suite( | ||
not_("parent suite name") | ||
) | ||
), | ||
not_( | ||
has_suite( | ||
not_("suite name") | ||
) | ||
), | ||
not_( | ||
has_sub_suite( | ||
not_("sub suite name") | ||
) | ||
) | ||
) | ||
) | ||
|
||
|
||
@allure.issue("586", "Issue 586") | ||
def test_custom_dynamic_suites(allure_pytest_runner: AllurePytestRunner): | ||
allure_results = allure_pytest_runner.run_docpath_examples(cache=True) | ||
|
||
assert_that( | ||
allure_results, | ||
has_test_case( | ||
"TestCustomDynamicSuites#test_custom_dynamic_suites", | ||
has_suite("suite name"), | ||
has_parent_suite("parent suite name"), | ||
has_sub_suite("sub suite name"), | ||
not_( | ||
has_parent_suite( | ||
not_("parent suite name") | ||
) | ||
), | ||
not_( | ||
has_suite( | ||
not_("suite name") | ||
) | ||
), | ||
not_( | ||
has_sub_suite( | ||
not_("sub suite name") | ||
) | ||
) | ||
) | ||
) |