Skip to content

Commit

Permalink
Improve tests a bit
Browse files Browse the repository at this point in the history
Use a normal function instead of a lambda
Parametrize test about suite name option
  • Loading branch information
nicoddemus committed May 12, 2017
1 parent 2ab8d12 commit f39f416
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions testing/test_junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,8 @@ def __init__(self):
self.pluginmanager = self
self.option = self

getini = lambda self, name: "pytest"
def getini(self, name):
return "pytest"

junitprefix = None
# XXX: shouldnt need tmpdir ?
Expand Down Expand Up @@ -1036,20 +1037,16 @@ class Report(BaseReport):
assert (test_case.getAttribute('url') == test_url), "The URL did not get written to the xml"


def test_set_suite_name(testdir):
testdir.makepyfile("""
import pytest
def test_func():
pass
""")
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")


def test_set_suite_name_default(testdir):
@pytest.mark.parametrize('suite_name', ['my_suite', ''])
def test_set_suite_name(testdir, suite_name):
if suite_name:
testdir.makeini("""
[pytest]
junit_suite_name={0}
""".format(suite_name))
expected = suite_name
else:
expected = 'pytest'
testdir.makepyfile("""
import pytest
Expand All @@ -1059,4 +1056,5 @@ def test_func():
result, dom = runandparse(testdir)
assert result.ret == 0
node = dom.find_first_by_tag("testsuite")
node.assert_attr(name="pytest")
node.assert_attr(name=expected)

0 comments on commit f39f416

Please sign in to comment.