Skip to content

Commit

Permalink
fix: address PytestUnknownMarkWarning
Browse files Browse the repository at this point in the history
As of pytest 4.5.0, a new warning is raised when the plugin doesn't
register its markers. See pytest-dev/pytest#5177

The docs recommend registering custom markers:
https://docs.pytest.org/en/latest/writing_plugins.html#registering-markers

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman committed May 15, 2019
1 parent 16aeee9 commit 71ae1d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions pytest_black.py
Expand Up @@ -30,6 +30,7 @@ def pytest_configure(config):
# load cached mtimes at session startup
if config.option.black and hasattr(config, "cache"):
config._blackmtimes = config.cache.get(HISTKEY, {})
config.addinivalue_line("markers", "black: enable format checking with black")


def pytest_unconfigure(config):
Expand Down
18 changes: 18 additions & 0 deletions tests/test_black.py
Expand Up @@ -116,3 +116,21 @@ def hello():

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


def test_pytest_deprecation_warning(testdir):
"""Assert no deprecation warning is raised during test."""
p = testdir.makepyfile(
"""
def hello():
print("Hello, world!")
"""
)
# replace trailing newline (stripped by testdir.makepyfile)
p = p.write(p.read() + "\n")

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

out = "\n".join(result.stdout.lines)
assert "PytestUnknownMarkWarning" not in out

0 comments on commit 71ae1d0

Please sign in to comment.