Skip to content

Pytest test discovery confused by packages #3936

Closed

Description

Environment data

  • VS Code version: 1.30.2
  • Extension version (available under the Extensions sidebar): 2018.12.1
  • Relevant/affected Python packages and their versions: pytest 3.9.1

Expected behaviour

Tests are discovered correctly

Actual behaviour

Any package causes subsequently discovered tests to be considered IN the package

Steps to reproduce:

  1. Create a tests folder
  2. Create test/testa/test_first.py test/testc/test_last.py with regular python tests (any function will suffice)
  3. Create test/testb/init.py and test/testb/test_second.py with a python test function
  4. Run discover tests

Logs

Example pytest output:

============================= test session starts ==============================
platform linux -- Python 3.6.0, pytest-3.9.1, py-1.7.0, pluggy-0.8.0
Using --randomly-seed=1547049040
rootdir: /home/alex/git/HP-DLF, inifile:
plugins: repeat-0.7.0, randomly-1.2.3, profiling-1.3.0, cov-2.6.0, console-scripts-0.1.7, nbval-0.9.1
collected 3 items
<Module 'test/testa/test_first.py'>
  <Function 'test_foo'>
<Package '/home/.../test/testb'>
  <Module 'test_second.py'>
    <Function 'test_foo'>
<Module 'test/testc/test_last.py'>
  <Function 'test_foo'>

========================= no tests ran in 0.11 seconds =========================

The test output parser will report the last one in file /home/.../test/testb/test/testc/test_last.py which is clearly wrong.

Reason is that the packagePrefix is not reset

Activity

  1. ghost added
    triage-needed
    on Jan 9, 2019
  2. added
    bug
    on Jan 9, 2019
  3. ghost removed
    triage-needed
    on Jan 9, 2019
  4. ghost removed
    triage-needed
    on Jan 9, 2019
  5. Flamefire commented on Jan 9, 2019

    @Flamefire
    Author

    I have a solution for this and can open a PR.

  6. added 3 commits that reference this issue on Jan 9, 2019
    bd4e2d6
    5df09fd
    ee596a6
  7. added a commit that references this issue on Feb 8, 2019
    78ebcc2
  8. DonJayamanne commented on Feb 27, 2019

    @DonJayamanne

    Eric Snow (@ericsnowcurrently) Please ensure your python code works in this scenario, if it does, then we can close this.
    Just need to ensure this gets tracked and tested, hence assigning to you & myself.

  9. 2 remaining items

  10. added a commit that references this issue on Mar 6, 2019
    c7d2693
  11. added a commit that references this issue on Mar 21, 2019
    19f9a00
  12. sleighsoft commented on Apr 9, 2019

    @sleighsoft

    Any time frame on when this will be released? It currently makes the pytest integration unusable for me.

  13. Flamefire commented on Apr 9, 2019

    @Flamefire
    Author

    I compiled the latest master locally and for me it is working. If it isn't for you you may watch #4795 which seems to contain the actual implementation of the Python based discovery.

  14. sleighsoft commented on Apr 10, 2019

    @sleighsoft

    Thanks Alexander Grund (@Flamefire). I just don't want to spend time compiling. I hope they supply an update soon.

  15. sleighsoft commented on Apr 18, 2019

    @sleighsoft

    Seems to have not made it into release 1.33.1 :/

  16. thatbudakguy commented on Jun 25, 2019

    @thatbudakguy

    Can we get an update on when this will be released?

  17. ericsnowcurrently commented on Sep 3, 2019

    @ericsnowcurrently

    This should be resolved in the most recent versions of the Python extension. If that is not the case then please create a new issue. (This one has a bit of outdated info, so better to start fresh.)

  18. ghost removed on Sep 3, 2019
  19. locked as resolved and limited conversation to collaborators on Sep 10, 2019
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

    area-testingbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions