pytest-relaxed
pytest-relaxed copied to clipboard
This plugin should not enable itself automatically
Apparently installing pytest-relaxed causes the 'relaxed' rules to start applying automatically to all projects. This is causing huge breakage for Gentoo. Two example packages affected by this are hpack and pyftpdlib.
Could you please make the plugin disable new behavior by default, and require explicitly enabling it via command-line, like most of pytest plugins seem to do?
I wish I'd been cognizant of this when I first wrote it. Changing this now will be backwards incompatible, but I'm probably still the biggest user of this (in my other projects) so yea I'll look into fixing this & putting out a major release version at some point 😐
Another example: pytest-xdist also affected, when pytest-relaxed is installed.
We either need this (all pytest plugins, actually) disabled by default, and/or a command line method in pytest to deterministically disable all plugins that aren't otherwise explicitly enabled by the test suite being run
I wish I'd been cognizant of this when I first wrote it. Changing this now will be backwards incompatible, but I'm probably still the biggest user of this (in my other projects) so yea I'll look into fixing this & putting out a major release version at some point 😐
👋 You could add a --relax
argument with:
def pytest_addoption(parser):
group = parser.getgroup("pytest-relaxed")
group.addoption('--relax',
action="store_true",
help='Enable pytest-relaxed')
https://docs.pytest.org/en/latest/reference.html#_pytest.hookspec.pytest_addoption
Then, to solve the backwards incompatibility problems, you would need to add documentation for users. Either, they add --relaxed
on command line, or they add it into pytest.ini
(etc.) under addopts
.
[pytest]
addopts =
--relaxed
https://docs.pytest.org/en/latest/reference.html#configuration-options
In your other projects, I would suggest the latter.
Oh, and check for relaxed
in pytest_configure
:
https://github.com/bitprophet/pytest-relaxed/blob/8e4d698e92b4fb2d7af7b1ae8c7e2f0ee6fe66da/pytest_relaxed/plugin.py#L34-L44
def pytest_conifgure(config):
if (config.getoption('collectonly')
or config.getoption('markers')
or config.getoption('showfixtures')):
pass
elif not config.getoption('relaxed'):
return
...
Edit: Added condition for collectonly
, etc.
sounds like this is just waiting for a PR, anyone up for it?