Skip to content

Discovery lens not working with pytest >= 3.7 #2663

Closed

Description

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

Activity

  1. brettcannon commented on Sep 24, 2018

    @brettcannon
    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.

  2. CaselIT commented on Sep 24, 2018

    @CaselIT
    Author

    thanks. hopefully it will be solved by pytest

  3. RonnyPfannschmidt commented on Sep 26, 2018

    @RonnyPfannschmidt

    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

  4. brettcannon commented on Sep 27, 2018

    @brettcannon
    Member

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

  5. locked as resolved and limited conversation to collaborators on Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions