GeezerVison is showing github.com — exclude duplicate links in report (via #414) · onefar/allure-python@a0fa2ca
File treeExpand file treeCollapse file tree Open diff view settings allure-python-commons-test/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: allure-pytest/src/listener.py +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -242,8 +242,12 @@ def add_link(self, url, link_type, name): | 242 | 242 | test_result = self.allure_logger.get_test(None) | 243 | 243 | if test_result: | 244 | 244 | pattern = dict(self.config.option.allure_link_pattern).get(link_type, u'{}') | 245 | | - url = pattern.format(url) | 246 | | - test_result.links.append(Link(link_type, url, name)) | | 245 | + link_url = pattern.format(url) | | 246 | + new_link = Link(link_type, link_url, link_url if name is None else name) | | 247 | + for link in test_result.links: | | 248 | + if link.url == new_link.url: | | 249 | + return | | 250 | + test_result.links.append(new_link) | 247 | 251 |
| 248 | 252 | @allure_commons.hookimpl | 249 | 253 | def add_label(self, label_type, labels): | |
Collapse file Copy file name to clipboardExpand all lines: allure-pytest/test/acceptance/link/dynamic_link_test.py +14-2Lines changed: 14 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | """ ./examples/link/dynamic_link.rst """ | 2 | 2 |
| 3 | 3 | import pytest | 4 | | -from hamcrest import assert_that | | 4 | +from hamcrest import assert_that, equal_to | 5 | 5 | from allure_commons_test.report import has_test_case | 6 | 6 | from allure_commons_test.result import has_link | 7 | 7 | from allure_commons_test.result import has_issue_link | @@ -28,7 +28,19 @@ def test_all_links_together(executed_docstring_path): | 28 | 28 | assert_that(executed_docstring_path.allure_report, | 29 | 29 | has_test_case("test_all_links_together", | 30 | 30 | has_issue_link("issues/24"), | 31 | | - has_issue_link("issues/24"), | | 31 | + has_issue_link("issues/132"), | 32 | 32 | has_link("allure", name="QAMETA", link_type="docs") | 33 | 33 | ) | 34 | 34 | ) | | 35 | + | | 36 | + | | 37 | +def test_unique_dynamic_links(executed_docstring_source): | | 38 | + """ | | 39 | + >>> import allure | | 40 | +
| | 41 | + >>> def test_unique_dynamic_links_example(): | | 42 | + ... allure.dynamic.link("some/unique/dynamic/link") | | 43 | + ... allure.dynamic.link("some/unique/dynamic/link") | | 44 | + """ | | 45 | + assert_that(executed_docstring_source.allure_report.test_cases[0]['links'], | | 46 | + equal_to([{'url': u'some/unique/dynamic/link', 'type': 'link', 'name': u'some/unique/dynamic/link'}])) |
Collapse file Copy file name to clipboardExpand all lines: allure-python-commons-test/src/result.py -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -159,4 +159,3 @@ def with_trace_contains(string): | 159 | 159 |
| 160 | 160 | def has_history_id(): | 161 | 161 | return has_entry('historyId', anything()) | 162 | | - |
|