Improve tests a bit
Use a normal function instead of a lambda Parametrize test about suite name option
This commit is contained in:
parent
2ab8d12fe3
commit
f39f416c5d
|
@ -616,7 +616,8 @@ def test_dont_configure_on_slaves(tmpdir):
|
||||||
self.pluginmanager = self
|
self.pluginmanager = self
|
||||||
self.option = self
|
self.option = self
|
||||||
|
|
||||||
getini = lambda self, name: "pytest"
|
def getini(self, name):
|
||||||
|
return "pytest"
|
||||||
|
|
||||||
junitprefix = None
|
junitprefix = None
|
||||||
# XXX: shouldnt need tmpdir ?
|
# XXX: shouldnt need tmpdir ?
|
||||||
|
@ -1036,20 +1037,16 @@ def test_url_property(testdir):
|
||||||
assert (test_case.getAttribute('url') == test_url), "The URL did not get written to the xml"
|
assert (test_case.getAttribute('url') == test_url), "The URL did not get written to the xml"
|
||||||
|
|
||||||
|
|
||||||
def test_set_suite_name(testdir):
|
@pytest.mark.parametrize('suite_name', ['my_suite', ''])
|
||||||
testdir.makepyfile("""
|
def test_set_suite_name(testdir, suite_name):
|
||||||
import pytest
|
if suite_name:
|
||||||
|
testdir.makeini("""
|
||||||
def test_func():
|
[pytest]
|
||||||
pass
|
junit_suite_name={0}
|
||||||
""")
|
""".format(suite_name))
|
||||||
result, dom = runandparse(testdir, '-o', "junit_suite_name=my_suite")
|
expected = suite_name
|
||||||
assert result.ret == 0
|
else:
|
||||||
node = dom.find_first_by_tag("testsuite")
|
expected = 'pytest'
|
||||||
node.assert_attr(name="my_suite")
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_suite_name_default(testdir):
|
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -1059,4 +1056,5 @@ def test_set_suite_name_default(testdir):
|
||||||
result, dom = runandparse(testdir)
|
result, dom = runandparse(testdir)
|
||||||
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="pytest")
|
node.assert_attr(name=expected)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue