File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99* Add ``buffer `` attribute to stdin stub class ``pytest.capture.DontReadFromInput ``
1010 Thanks `@joguSD `_ for the PR.
1111
12- *
12+ * Testcase reports with a url attribute will now properly write this to junitxml.
13+ Thanks `@fushi `_ for the PR
14+
1315
1416.. _@joguSD : https://github.com/joguSD
17+ .. _@fushi : https://github.com/fushi
1518
1619.. _#1857 : https://github.com/pytest-dev/pytest/issues/1857
1720
Original file line number Diff line number Diff 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 ):
Original file line number Diff line number Diff 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"
You can’t perform that action at this time.
0 commit comments