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

Ringo De Smet ringo.de.smet at ontoforce.com
Mon Mar 12 12:08:11 EDT 2018


I am in the process of implementing a pytest plugin to run mamba tests as a
pytest plugin. Running pytest without any arguments works correctly: pytest
picks up tests using the python and unittest plugins from the tests folder
and picks up the mamba tests from the spec folder.

The problem starts when running pytest with a single spec file as argument:

$ pytest spec/action_base_spec.py
test session starts
platform darwin -- Python 3.6.4, pytest-3.4.1, py-1.5.2, pluggy-0.6.0
rootdir: /Users/ringods/Projects/ontoforce/metis/execution_layer, inifile:
plugins: mamba-1.0.0
collected 6 items / 1 errors

____________________________________________________________ ERROR
collecting spec/action_base_spec.py
spec/action_base_spec.py:20: in <module>
    with description('ActionBase') as self:
E   AttributeError: __enter__
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted:
1 errors during collection
===================================================================== 1
error in 0.15 seconds

This comes from the python plugin in pytest. When running with `-p
no:python`, this command succeeds.

Why is the python plugin picking up this file, even when it doesn't match
the regexes `test_*.py` or `*_test.py`?

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

More information about the pytest-dev mailing list