Hi Ringo, On Tue, Mar 13, 2018 at 4:40 AM Ringo De Smet <ringo.de.s...@ontoforce.com> wrote:
> Ronny, Bruno, > > On Mon, Mar 12, 2018 at 8:10 PM, Bruno Oliveira <nicodde...@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? > The only way I can think of right now is to pass `-p no:python` in the command line to explicitly disable the Python plugin, as you mention. 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. > Oh my bad, indeed all return values of `pytest_collect_file` are processed. This is by design, that allows `--doctest-modules` to process docstrings in test files (for example). But looking at your original error more closely: ``` spec/action_base_spec.py:20: in <module> with description('ActionBase') as self: E AttributeError: __enter__ ``` It is not clear to me why this is breaking because of the python plugin; can you share `action_base_spec.py` and your plugin code? Cheers, Bruno.
_______________________________________________ pytest-dev mailing list firstname.lastname@example.org https://mail.python.org/mailman/listinfo/pytest-dev