diff --git a/pytest_black.py b/pytest_black.py index 83c29e9..1b68de3 100644 --- a/pytest_black.py +++ b/pytest_black.py @@ -45,7 +45,7 @@ def pytest_unconfigure(config): class BlackItem(pytest.Item, pytest.File): def __init__(self, fspath, parent): super(BlackItem, self).__init__(fspath, parent) - self._nodeid += "::BLACK" + self._nodeid += "-BLACK" self.add_marker("black") try: with open("pyproject.toml") as toml_file: diff --git a/tests/test_black.py b/tests/test_black.py index 91ba79e..b6497ad 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +from xml import dom +from xml.dom.minidom import parse import pytest @@ -139,3 +141,15 @@ def hello(): out = "\n".join(result.stdout.lines) assert "PytestUnknownMarkWarning" not in out + + +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")