Skip to content

Commit dc16fe2

Browse files
committed
Merge junit-xml url attribute branch
Merge branch 'url_attr' of https://github.com/fushi/pytest into junitxml-url
2 parents 5b260d8 + 1b259f7 commit dc16fe2

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
3.1.0.dev
22
=========
33

4-
*
4+
* Testcase reports with a url attribute will now properly write this to junitxml.
5+
Thanks `@fushi`_ for the PR
56

67
*
78

@@ -11,6 +12,8 @@
1112

1213
*
1314

15+
.. _@fushi: https://github.com/fushi
16+
1417

1518
3.0.2
1619
=====
@@ -35,7 +38,7 @@
3538
enabled. This allows proper post mortem debugging for all applications
3639
which have significant logic in their tearDown machinery (`#1890`_). Thanks
3740
`@mbyt`_ for the PR.
38-
41+
3942
* Fix use of deprecated ``getfuncargvalue`` method in the internal doctest plugin.
4043
Thanks `@ViviCoder`_ for the report (`#1898`_).
4144

_pytest/junitxml.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def record_testreport(self, testreport):
102102
}
103103
if testreport.location[1] is not None:
104104
attrs["line"] = testreport.location[1]
105+
if hasattr(testreport, "url"):
106+
attrs["url"] = testreport.url
105107
self.attrs = attrs
106108

107109
def to_xml(self):

testing/test_junitxml.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,3 +922,28 @@ class Report(BaseReport):
922922
actual[k] = v
923923

924924
assert actual == expected
925+
926+
927+
def test_url_property(testdir):
928+
test_url = "http://www.github.com/pytest-dev"
929+
path = testdir.tmpdir.join("test_url_property.xml")
930+
log = LogXML(str(path), None)
931+
from _pytest.runner import BaseReport
932+
933+
class Report(BaseReport):
934+
longrepr = "FooBarBaz"
935+
sections = []
936+
nodeid = "something"
937+
location = 'tests/filename.py', 42, 'TestClass.method'
938+
url = test_url
939+
940+
test_report = Report()
941+
942+
log.pytest_sessionstart()
943+
node_reporter = log._opentestcase(test_report)
944+
node_reporter.append_failure(test_report)
945+
log.pytest_sessionfinish()
946+
947+
test_case = minidom.parse(str(path)).getElementsByTagName('testcase')[0]
948+
949+
assert (test_case.getAttribute('url') == test_url), "The URL did not get written to the xml"

0 commit comments

Comments
 (0)