diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py index 5240e0e28..301633706 100644 --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -226,19 +226,14 @@ def pytest_addoption(parser): metavar="str", default=None, help="prepend prefix to classnames in junit-xml output") - group.addoption( - '--junitsuitename', '--junit-suite-name', - action="store", - metavar="name", - default="pytest", - help="set the name attribute of root tag") + parser.addini("junit_suite_name", "Test suite name for JUnit report", default="pytest") def pytest_configure(config): xmlpath = config.option.xmlpath # prevent opening xmllog on slave nodes (xdist) if xmlpath and not hasattr(config, 'slaveinput'): - config._xml = LogXML(xmlpath, config.option.junitprefix, config.option.junitsuitename) + config._xml = LogXML(xmlpath, config.option.junitprefix, config.getini("junit_suite_name")) config.pluginmanager.register(config._xml) diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 417f8cca6..9735f45ef 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -616,8 +616,9 @@ def test_dont_configure_on_slaves(tmpdir): self.pluginmanager = self self.option = self + getini = lambda self, name: "pytest" + junitprefix = None - junitsuitename = "pytest" # XXX: shouldnt need tmpdir ? xmlpath = str(tmpdir.join('junix.xml')) register = gotten.append @@ -1042,7 +1043,7 @@ def test_set_suite_name(testdir): def test_func(): pass """) - result, dom = runandparse(testdir, '--junit-suite-name', "my_suite") + result, dom = runandparse(testdir, '-o', "junit_suite_name=my_suite") assert result.ret == 0 node = dom.find_first_by_tag("testsuite") node.assert_attr(name="my_suite")