Skip to content

Discovery lens not working with pytest >= 3.7 #2663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CaselIT opened this issue Sep 23, 2018 · 4 comments
Closed

Discovery lens not working with pytest >= 3.7 #2663

CaselIT opened this issue Sep 23, 2018 · 4 comments

Comments

@CaselIT
Copy link

CaselIT commented Sep 23, 2018

When discovering test with pytest>=3.7 if the test directory is a package the reported files do not include their path if they are in a subfolder.

With a file structure like

- tests
|- __init__.py
|- bar_test.py
|- subfolder
   |- foo_test.py

The reported output of pytest is

<Package 'C:\\path\\to\\pytest-discovery-bug\\tests_package'>
  <Module 'bar_test.py'>
    ...
  <Module 'foo_test.py'>
    ...

There is no indication that foo_test.py is inside the folder subfolder, so the extension fails to show the lens on the file subfolder/foo_test.py

I've created a minimal example: https://github.com/CaselIT/pytest-discovery-bug

I've reported the bug also on the pytest repo pytest-dev/pytest#4024, since it seems to be an issue of pytest.

I'm opening this to check if there is a work around to this issue in the meantime

Environment data

  • VS Code version: 1.27.2
  • Extension version (available under the Extensions sidebar): 2018.8.0
  • OS and version: windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.6
@brettcannon
Copy link
Member

Unfortunately there isn't a work-around short of you adding a __init__.py into your subfolder directory so pytest will then surface the appropriate information that we need to be able to reference foo_test.py.

@CaselIT
Copy link
Author

CaselIT commented Sep 24, 2018

thanks. hopefully it will be solved by pytest

@RonnyPfannschmidt
Copy link

note that you shouldn't just parse text output of pytest - you should invoke it with a plugin instead that correctly collects the internal details

@brettcannon
Copy link
Member

@RonnyPfannschmidt yep, we know. 😄 Plan to address it when we clean-up our testing scenarios.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants