File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 9
9
* Add ``buffer `` attribute to stdin stub class ``pytest.capture.DontReadFromInput ``
10
10
Thanks `@joguSD `_ for the PR.
11
11
12
- *
12
+ * Testcase reports with a url attribute will now properly write this to junitxml.
13
+ Thanks `@fushi `_ for the PR
14
+
13
15
14
16
.. _@joguSD : https://github.com/joguSD
17
+ .. _@fushi : https://github.com/fushi
15
18
16
19
.. _#1857 : https://github.com/pytest-dev/pytest/issues/1857
17
20
Original file line number Diff line number Diff line change @@ -102,6 +102,8 @@ def record_testreport(self, testreport):
102
102
}
103
103
if testreport .location [1 ] is not None :
104
104
attrs ["line" ] = testreport .location [1 ]
105
+ if hasattr (testreport , "url" ):
106
+ attrs ["url" ] = testreport .url
105
107
self .attrs = attrs
106
108
107
109
def to_xml (self ):
Original file line number Diff line number Diff line change @@ -922,3 +922,28 @@ class Report(BaseReport):
922
922
actual [k ] = v
923
923
924
924
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"
You can’t perform that action at this time.
0 commit comments