Transition to using ini option for suite name
This commit is contained in:
parent
bcfa6264f1
commit
c9282f9e94
|
@ -226,19 +226,14 @@ def pytest_addoption(parser):
|
||||||
metavar="str",
|
metavar="str",
|
||||||
default=None,
|
default=None,
|
||||||
help="prepend prefix to classnames in junit-xml output")
|
help="prepend prefix to classnames in junit-xml output")
|
||||||
group.addoption(
|
parser.addini("junit_suite_name", "Test suite name for JUnit report", default="pytest")
|
||||||
'--junitsuitename', '--junit-suite-name',
|
|
||||||
action="store",
|
|
||||||
metavar="name",
|
|
||||||
default="pytest",
|
|
||||||
help="set the name attribute of root <testsuite> tag")
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
xmlpath = config.option.xmlpath
|
xmlpath = config.option.xmlpath
|
||||||
# prevent opening xmllog on slave nodes (xdist)
|
# prevent opening xmllog on slave nodes (xdist)
|
||||||
if xmlpath and not hasattr(config, 'slaveinput'):
|
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)
|
config.pluginmanager.register(config._xml)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -616,8 +616,9 @@ def test_dont_configure_on_slaves(tmpdir):
|
||||||
self.pluginmanager = self
|
self.pluginmanager = self
|
||||||
self.option = self
|
self.option = self
|
||||||
|
|
||||||
|
getini = lambda self, name: "pytest"
|
||||||
|
|
||||||
junitprefix = None
|
junitprefix = None
|
||||||
junitsuitename = "pytest"
|
|
||||||
# XXX: shouldnt need tmpdir ?
|
# XXX: shouldnt need tmpdir ?
|
||||||
xmlpath = str(tmpdir.join('junix.xml'))
|
xmlpath = str(tmpdir.join('junix.xml'))
|
||||||
register = gotten.append
|
register = gotten.append
|
||||||
|
@ -1042,7 +1043,7 @@ def test_set_suite_name(testdir):
|
||||||
def test_func():
|
def test_func():
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
result, dom = runandparse(testdir, '--junit-suite-name', "my_suite")
|
result, dom = runandparse(testdir, '-o', "junit_suite_name=my_suite")
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
node = dom.find_first_by_tag("testsuite")
|
node = dom.find_first_by_tag("testsuite")
|
||||||
node.assert_attr(name="my_suite")
|
node.assert_attr(name="my_suite")
|
||||||
|
|
Loading…
Reference in New Issue