Transition to using ini option for suite name

This commit is contained in:
Dmitri Pribysh 2017-05-12 04:45:20 +03:00 committed by Bruno Oliveira
parent bcfa6264f1
commit c9282f9e94
2 changed files with 5 additions and 9 deletions

View File

@ -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 <testsuite> 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)

View File

@ -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")