diff --git a/pytest_black.py b/pytest_black.py index fc678c9..567afb8 100644 --- a/pytest_black.py +++ b/pytest_black.py @@ -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): diff --git a/tests/test_black.py b/tests/test_black.py index f164ecf..e01c318 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -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