Closed aklajnert closed 3 months ago
Another idea would be to use virtualenvs:
pip install --no-index --find-lines file://path/to/wheels/ pytest-cov pytest
pytest itself is implemented using plugins so disabling all of them isn't really feasible
Actually, I meant only the third-party plugins. Those that are listed within the plugins
section on the pytest summary.
Also, for debugging purposes it is sometimes useful to disable most plugins (or all).
but you can also disable internal plugins, where to draw the line?
either way I don't think this is a good idea to implement -- just make another environment without the plugins installed imo
lets rephrase the use-case a bit
i believe @aklajnert wants to switch from auto-loading distribution based plugins to explicitly loading only a select set of them
excluding/including plugins based on the distribution name as well as disabling setuptools auto-loading are both useful features, that in combination would enable the use-case @aklajnert described
Right. For now, we disable most of the plugins we don't want with the -p no:plugin
. It doesn't work in the same way and is sometimes hard since the plugin disabling can be tricky (#5661).
I would argue that the default situation should be to only load plugins (3rd-party in particular) relevant to the module being tested. At the moment pytest loads every single plugin that happens to be installed on the system, and this causes problems when there are collisions between plugins.
The biggest problem that regularly pops up is the Xvfb plugin (pytest-xvfb). It's very useful for packages that are expecting to use it, but for other packages it just generates unnecessary errors, e.g. https://github.com/qutip/qutip/issues/1639 . It would be better if pytest-xvfb were not loaded automatically.
The PYTEST_DISABLE_PLUGIN_AUTOLOAD
env var should solve (most of) this problem, with https://github.com/pytest-dev/pytest/issues/8969 for further configuration.
Currently, it is possible to disable a plugin by using
-p no:plugin
. There is however one feature that is missing for us, which is kind of the opposite. I want to disable all plugins but few selected.E.g. if I'll run
pytest -p only:plugin1 -p only:plugin2
, the pytest should disable all the plugins exceptplugin1
andplugin2
.Our use case is that we have few hosts behind a firewall which makes modules installation very hard. To circumvent it, we have a common directory with pytest and some plugins. In some cases, we want to disable some of them, but since they can be added any time it would be useful to select only the plugins we need and ignore everything else.