Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytest_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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

import pytest

Expand Down Expand Up @@ -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")