Skip to content

Test should be re-discovered after switching environment. #5347

Closed

Description

Environment data

  • VS Code version: 1.33.1
  • Extension version (available under the Extensions sidebar): master
  • OS and version: Any
  • Python version (& distribution if applicable, e.g. Anaconda): Any
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A

Expected behavior

I have 2.7 and 3.7. If I have pytests in only in 3.7. If i was using 3.7 discovered tests then switched environments then the test explorer should be empty. Also there should be some indication of why the test discovery failed. Pytest not installed.

In the case of ptvsd, test discovery fails because of a issue in conftest.py (only on 2.7). But this is not clear, because the tests are not re-discovered when switching between 3.7 and 2.7.

ImportError while loading conftest 'c:\GIT\ptvsd\tests\conftest.py'.
C:\Users\kanadig\AppData\Roaming\Python\Python27\site-packages\six.py:709: in exec_
    exec("""exec _code_ in _globs_, _locs_""")
tests\conftest.py:16: in <module>
    from . import helpers
tests\helpers\__init__.py:92: in <module>
    from .printer import print
C:\Users\kanadig\AppData\Roaming\Python\Python27\site-packages\six.py:709: in exec_
    exec("""exec _code_ in _globs_, _locs_""")
tests\helpers\printer.py:10: in <module>
    from .ptvsd.compat import queue
E   ImportError: No module named ptvsd.compat

Actual behavior

Test explorer retains the discovered test from the previous environment.

Steps to reproduce:

  1. Open ptvsd project with 3.7

  2. Discover tests

  3. Open test explorer

  4. Change python to 2.7

  5. Test should be rediscovered (should be empty for ptvsd due to a issue with detecting tests)

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on Apr 17, 2019
  2. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Apr 17, 2019
  3. karrtikr commented on Jul 29, 2021

    @karrtikr

    Still happens. Previously discovered test nodes are not removed when virtual env is changed. So even though discovery maybe retriggered.
    image

  4. brettcannon commented on Aug 3, 2021

    @brettcannon
    Member

    This is verified in the new test UI.

  5. locked as resolved and limited conversation to collaborators on Sep 16, 2021
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions