Skip to content

Commit

Permalink
Make sure informative file name make it to the XML report
Browse files Browse the repository at this point in the history
  • Loading branch information
silviot committed May 14, 2019
1 parent 16aeee9 commit d72c449
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pytest_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def pytest_unconfigure(config):
class BlackItem(pytest.Item, pytest.File):
def __init__(self, path, parent):
super(BlackItem, self).__init__(path, parent)
self._nodeid += "::BLACK"
self._nodeid += "-BLACK"
self.add_marker("black")
try:
with open("pyproject.toml") as toml_file:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_black.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from xml import dom
from xml.dom.minidom import parse


def test_help_message(testdir):
Expand Down Expand Up @@ -116,3 +118,15 @@ def hello():

result = testdir.runpytest("--black")
result.assert_outcomes(skipped=0, passed=1)


def test_names(testdir):
"""Assert test names are informative about what file was tested
"""
file = testdir.makepyfile('def hello():\n print("Hello, world!")')
file.write(data="\n", mode="a")

testdir.runpytest("--black", "--junit-xml=test-output.xml")
dom = parse((testdir.tmpdir / "test-output.xml").open())
test_case = dom.getElementsByTagName("testcase")[0]
assert "test_names.py" in test_case.getAttribute("name")

0 comments on commit d72c449

Please sign in to comment.