Custom marks don't play nice with pytest_plugins = ('my_plugin',)
in test file
#9677
Labels
plugin: warnings
related to the warnings builtin plugin
topic: config
related to config handling, argument parsing and config file
topic: marks
related to marks, either the general marks or builtin
I've got a pytest plugin that registers a custom mark in the
pytest_configure
hook usingconfig.addinivalue_line
. When I load my plugin by puttingpytest_plugins = ("my_plugin",)
in my test file (as described here) and add the mark to one of my tests, I still get a warningPytestUnknownMarkWarning: Unknown pytest.mark.my_mark - is this a typo?
When I load my plugin by putting
pytest_plugins = ("my_plugin",)
in theconftest.py
file, I do not get the warning.Here's my example plugin:
Here's the test file that triggers the warning:
Here's my environment
I'm aware that I can use a setuptools entrypoint to install my plugin, but that isn't an option in the more complicated environment where I encountered the problem. Likewise, the use of
conftest.py
to load the plugin is a bit frowned upon - we're trying declare the plugins we're using in the test files themselves so they're more stand-alone readable (among other reasons).I suspect what's going wrong here is the warning is triggered during assertion re-writing in the test module. If I drop a breakpoint here I see the following near the end of the backtrace
That happens before my pytest_configure hook is run, so it has no idea that
my_mark
is a custom mark yet.Unfortunately, this is about the limit of my understanding so I can't be more helpful by trying stuff like "suppress this warning during assertion re-writing" to see if that fixes the problem. It's a bummer that this mark triggers a warning.
The text was updated successfully, but these errors were encountered: