Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure informative file name make it to the XML report #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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")