Elffuss BraidHub

kikocis/auto-code-rover public

main · 9.5 KiBRawPermalink
1{
2 "task_id": "pytest-dev__pytest-5692",
3 "setup_info": {
4 "repo_path": "/home/haifeng/projects/reverse-prompt/SWE-bench/testbed/pytest-dev__pytest/setup_pytest-dev__pytest__5.0",
5 "env_name": "setup_pytest-dev__pytest__5.0",
6 "pre_install": [],
7 "install": "python -m pip install -e .",
8 "test_cmd": "pytest -rA testing/test_junitxml.py"
9 },
10 "task_info": {
11 "instance_id": "pytest-dev__pytest-5692",
12 "base_commit": "29e336bd9bf87eaef8e2683196ee1975f1ad4088",
13 "hints_text": "",
14 "created_at": "2019-08-03T14:15:04Z",
15 "test_patch": "diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py\n--- a/testing/test_junitxml.py\n+++ b/testing/test_junitxml.py\n@@ -1,4 +1,6 @@\n import os\n+import platform\n+from datetime import datetime\n from xml.dom import minidom\n \n import py\n@@ -139,6 +141,30 @@ def test_xpass():\n node = dom.find_first_by_tag(\"testsuite\")\n node.assert_attr(name=\"pytest\", errors=1, failures=2, skipped=1, tests=5)\n \n+ def test_hostname_in_xml(self, testdir):\n+ testdir.makepyfile(\n+ \"\"\"\n+ def test_pass():\n+ pass\n+ \"\"\"\n+ )\n+ result, dom = runandparse(testdir)\n+ node = dom.find_first_by_tag(\"testsuite\")\n+ node.assert_attr(hostname=platform.node())\n+\n+ def test_timestamp_in_xml(self, testdir):\n+ testdir.makepyfile(\n+ \"\"\"\n+ def test_pass():\n+ pass\n+ \"\"\"\n+ )\n+ start_time = datetime.now()\n+ result, dom = runandparse(testdir)\n+ node = dom.find_first_by_tag(\"testsuite\")\n+ timestamp = datetime.strptime(node[\"timestamp\"], \"%Y-%m-%dT%H:%M:%S.%f\")\n+ assert start_time <= timestamp < datetime.now()\n+\n def test_timing_function(self, testdir):\n testdir.makepyfile(\n \"\"\"\n",
16 "repo": "pytest-dev/pytest",
17 "problem_statement": "Hostname and timestamp properties in generated JUnit XML reports\nPytest enables generating JUnit XML reports of the tests.\r\n\r\nHowever, there are some properties missing, specifically `hostname` and `timestamp` from the `testsuite` XML element. Is there an option to include them?\r\n\r\nExample of a pytest XML report:\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<testsuite errors=\"0\" failures=\"2\" name=\"check\" skipped=\"0\" tests=\"4\" time=\"0.049\">\r\n\t<testcase classname=\"test_sample.TestClass\" file=\"test_sample.py\" line=\"3\" name=\"test_addOne_normal\" time=\"0.001\"></testcase>\r\n\t<testcase classname=\"test_sample.TestClass\" file=\"test_sample.py\" line=\"6\" name=\"test_addOne_edge\" time=\"0.001\"></testcase>\r\n</testsuite>\r\n```\r\n\r\nExample of a junit XML report:\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<testsuite name=\"location.GeoLocationTest\" tests=\"2\" skipped=\"0\" failures=\"0\" errors=\"0\" timestamp=\"2019-04-22T10:32:27\" hostname=\"Anass-MacBook-Pro.local\" time=\"0.048\">\r\n <properties/>\r\n <testcase name=\"testIoException()\" classname=\"location.GeoLocationTest\" time=\"0.044\"/>\r\n <testcase name=\"testJsonDeserialization()\" classname=\"location.GeoLocationTest\" time=\"0.003\"/>\r\n <system-out><![CDATA[]]></system-out>\r\n <system-err><![CDATA[]]></system-err>\r\n</testsuite>\r\n```\n",
18 "version": "5.0",
19 "FAIL_TO_PASS": [
20 "testing/test_junitxml.py::TestPython::test_hostname_in_xml",
21 "testing/test_junitxml.py::TestPython::test_timestamp_in_xml"
22 ],
23 "PASS_TO_PASS": [
24 "testing/test_junitxml.py::TestNonPython::test_summing_simple",
25 "testing/test_junitxml.py::TestPython::test_assertion_binchars",
26 "testing/test_junitxml.py::TestPython::test_avoid_double_stdout",
27 "testing/test_junitxml.py::TestPython::test_call_failure_teardown_error",
28 "testing/test_junitxml.py::TestPython::test_classname_instance",
29 "testing/test_junitxml.py::TestPython::test_classname_nested_dir",
30 "testing/test_junitxml.py::TestPython::test_collect_error",
31 "testing/test_junitxml.py::TestPython::test_failure_escape",
32 "testing/test_junitxml.py::TestPython::test_failure_function[no]",
33 "testing/test_junitxml.py::TestPython::test_failure_function[system-err]",
34 "testing/test_junitxml.py::TestPython::test_failure_function[system-out]",
35 "testing/test_junitxml.py::TestPython::test_failure_verbose_message",
36 "testing/test_junitxml.py::TestPython::test_internal_error",
37 "testing/test_junitxml.py::TestPython::test_junit_duration_report[call]",
38 "testing/test_junitxml.py::TestPython::test_junit_duration_report[total]",
39 "testing/test_junitxml.py::TestPython::test_junit_prefixing",
40 "testing/test_junitxml.py::TestPython::test_mark_skip_contains_name_reason",
41 "testing/test_junitxml.py::TestPython::test_mark_skip_doesnt_capture_output",
42 "testing/test_junitxml.py::TestPython::test_mark_skipif_contains_name_reason",
43 "testing/test_junitxml.py::TestPython::test_pass_captures_stderr",
44 "testing/test_junitxml.py::TestPython::test_pass_captures_stdout",
45 "testing/test_junitxml.py::TestPython::test_setup_error",
46 "testing/test_junitxml.py::TestPython::test_setup_error_captures_stderr",
47 "testing/test_junitxml.py::TestPython::test_setup_error_captures_stdout",
48 "testing/test_junitxml.py::TestPython::test_skip_contains_name_reason",
49 "testing/test_junitxml.py::TestPython::test_summing_simple",
50 "testing/test_junitxml.py::TestPython::test_summing_simple_with_errors",
51 "testing/test_junitxml.py::TestPython::test_teardown_error",
52 "testing/test_junitxml.py::TestPython::test_timing_function",
53 "testing/test_junitxml.py::TestPython::test_unicode",
54 "testing/test_junitxml.py::TestPython::test_xfail_captures_output_once",
55 "testing/test_junitxml.py::TestPython::test_xfailure_function",
56 "testing/test_junitxml.py::TestPython::test_xfailure_marker",
57 "testing/test_junitxml.py::TestPython::test_xfailure_xpass",
58 "testing/test_junitxml.py::TestPython::test_xfailure_xpass_strict",
59 "testing/test_junitxml.py::test_dont_configure_on_slaves",
60 "testing/test_junitxml.py::test_double_colon_split_function_issue469",
61 "testing/test_junitxml.py::test_double_colon_split_method_issue469",
62 "testing/test_junitxml.py::test_escaped_parametrized_names_xml",
63 "testing/test_junitxml.py::test_escaped_skipreason_issue3533",
64 "testing/test_junitxml.py::test_fancy_items_regression",
65 "testing/test_junitxml.py::test_global_properties",
66 "testing/test_junitxml.py::test_invalid_xml_escape",
67 "testing/test_junitxml.py::test_logging_passing_tests_disabled_does_not_log_test_output",
68 "testing/test_junitxml.py::test_logxml_changingdir",
69 "testing/test_junitxml.py::test_logxml_check_isdir",
70 "testing/test_junitxml.py::test_logxml_makedir",
71 "testing/test_junitxml.py::test_logxml_path_expansion",
72 "testing/test_junitxml.py::test_mangle_test_address",
73 "testing/test_junitxml.py::test_nullbyte",
74 "testing/test_junitxml.py::test_nullbyte_replace",
75 "testing/test_junitxml.py::test_record_attribute",
76 "testing/test_junitxml.py::test_record_fixtures_without_junitxml[record_property]",
77 "testing/test_junitxml.py::test_record_fixtures_without_junitxml[record_xml_attribute]",
78 "testing/test_junitxml.py::test_record_fixtures_xunit2[record_property]",
79 "testing/test_junitxml.py::test_record_fixtures_xunit2[record_xml_attribute]",
80 "testing/test_junitxml.py::test_record_property",
81 "testing/test_junitxml.py::test_record_property_same_name",
82 "testing/test_junitxml.py::test_record_testsuite_property",
83 "testing/test_junitxml.py::test_record_testsuite_property_junit_disabled",
84 "testing/test_junitxml.py::test_record_testsuite_property_type_checking[False]",
85 "testing/test_junitxml.py::test_record_testsuite_property_type_checking[True]",
86 "testing/test_junitxml.py::test_root_testsuites_tag",
87 "testing/test_junitxml.py::test_runs_twice",
88 "testing/test_junitxml.py::test_set_suite_name[]",
89 "testing/test_junitxml.py::test_set_suite_name[my_suite]",
90 "testing/test_junitxml.py::test_unicode_issue368",
91 "testing/test_junitxml.py::test_url_property"
92 ],
93 "environment_setup_commit": "c2f762460f4c42547de906d53ea498dd499ea837",
94 "patch": "diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py\n--- a/src/_pytest/junitxml.py\n+++ b/src/_pytest/junitxml.py\n@@ -10,9 +10,11 @@\n \"\"\"\n import functools\n import os\n+import platform\n import re\n import sys\n import time\n+from datetime import datetime\n \n import py\n \n@@ -666,6 +668,8 @@ def pytest_sessionfinish(self):\n skipped=self.stats[\"skipped\"],\n tests=numtests,\n time=\"%.3f\" % suite_time_delta,\n+ timestamp=datetime.fromtimestamp(self.suite_start_time).isoformat(),\n+ hostname=platform.node(),\n )\n logfile.write(Junit.testsuites([suite_node]).unicode(indent=0))\n logfile.close()\n",
95 "pr_link": "https://github.com/pytest-dev/pytest/pull/5692"
96 }
97}