0

I may have missed this detail but I'm trying to see if I can control the set of plugins made available through the ini configuration itself.

I did not find that item enumerated in any of the configurable command-line options nor in any of the documentation around the pytest_plugins global.

The goal is to reuse a given test module with different fixture implementations.

jxramos
  • 7,356
  • 6
  • 57
  • 105
  • 1
    `addopts = -p my.plugin.module.full.name -p my.other.plugin.module.full.name` should work, assuming the sys.path is correct. – hoefling Dec 17 '20 at 14:17

1 Answers1

2

@hoefling is absolutely right, there is actually a pytest command line argument that can specify plugins to be used, which along with the addopts ini configuration can be used to select a set of plugin files, one per -p command.

As an example the following ini file selects three separate plugins, the plugins specified later in the list take precedence over those that came earlier.

projX.ini

addopts = 
    -p projX.plugins.plugin_1
    -p projX.plugins.plugin_2
    -p projY.plugins.plugin_1

We can then invoke this combination on a test module with a command like

python -m pytest projX -c projX.ini

A full experiment is detailed here in this repository https://github.com/jxramos/pytest_behavior/tree/main/ini_plugin_selection

jxramos
  • 7,356
  • 6
  • 57
  • 105