pytest: UsageError in package that contains pytest_plugins module

When running pytest --doctest-modules on a package that contains a pytest plugin, pytest errors out and produces a pretty long stacktrace. The code that triggers the error is the _get_plugin_specs_as_list function that receives a module object instead of a list or a string.

The behavior is OS-independent as far as I can tell, but affects only pytest 3.7+ ; pytest 3.6.4 works fine. Also note that the error is only triggered when doc-testing the specific subpackage that contains the plugin.

For proper context, we have the following directory structure:

odl
 |
 |- util --
 |        |- pytest_plugins.py
 |        |- ...
 | - ...

The error is triggered by pytest --doctest-modules odl/util.

The full backtrace is here. Link to the subpackage: https://github.com/odlgroup/odl/tree/master/odl/util

Edit: Updated pytest versions affected

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@nicoddemus @RonnyPfannschmidt @blueyed Thanks for looking into this. I think the issue sits deep and one has to be somewhat unlucky to hit it. So we’ll just change the name of the module. I can confirm that giving it some other name solves the problem.

The documentation on plugins doesn’t mention the case discussed here. If you think it’s worth giving it a brief mention, I can add a sentence to the docs.

We should probably issue a warning instead, instead of ignoring it.