[pytest-dev] Not running standard pytest collector for file spec/*_spec.py

Ringo De Smet ringo.de.smet at ontoforce.com
Tue Mar 13 03:39:54 EDT 2018


Ronny, Bruno,

On Mon, Mar 12, 2018 at 8:10 PM, Bruno Oliveira <nicoddemus at gmail.com>
wrote:

> Hi Ringo,
>
> It is as Ronny said, you can see the code responsible for that here:
>
> https://github.com/pytest-dev/pytest/blob/master/_pytest/python.py#L162
>
> When the file has a `.py` extension and is one of the "inipaths" (paths
> given explicitly in the command line), then the `python` plugin will
> collect that file anyway.
>

That's a pitty. Given the pluggability of pytest, each plugin could have a
way to collect files and offer test suites back to pytest. Isn't there a
way to specify one of my spec tests without the wrong plugin(s) picking up
this file?


>
> You can override this by implementing your own `pytest_collect_file` and
> return non-`None` when a `.py` file inside the specs directory is passed in
> the command-line.
>
>
 Bruno, my plugin is collecting the file specified on the command line
correctly, but still the python plugin tries to run it too. That's where it
goes wrong.

Ringo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20180313/d99fd2fe/attachment.html>


More information about the pytest-dev mailing list