Skip to content

re-running a pytest test causes it to run all tests in the workspace #338

Closed
microsoft/vscode-python
#24438

Description

@DetachHead

this started happening as of the latest vscode update (1.89.0)

to reproduce:

  1. put a breakpoint in a pytest test
    image
  2. right click the run button and click "Debug test"
  3. when it pauses on the breakpoint, click the restart button
    image
  4. check the debug console
    Traceback (most recent call last):
      File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main
        return _run_code(code, main_globals, None,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 88, in _run_code
        exec(code, run_globals)
      File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.6.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
        cli.main()
      File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.6.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
        run()
      File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.6.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
        runpy.run_path(target, run_name="__main__")
      File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.6.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
        return _run_module_code(code, init_globals, run_name,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.6.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.6.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
        exec(code, run_globals)
      File "c:\Users\user\.vscode\extensions\ms-python.python-2024.6.0\python_files\vscode_pytest\run_pytest_script.py", line 62, in <module>
        test_ids_from_buffer = raw_json["params"]
                               ~~~~~~~~^^^^^^^^^^
    KeyError: 'params'
    

Activity

  1. brenoimatos commented on May 7, 2024

    @brenoimatos

    Same thing happening here.

  2. alfonzso commented on May 15, 2024

    @alfonzso

    Workaround (till not fixed): install/downgrade ms-python.python == 2024.4.1 version.

  3. golgor commented on May 17, 2024

    @golgor

    Also started experiencing this. Thanks for the workaround Zsolt Alföldi (@alfonzso)!

  4. iiwolf commented on May 24, 2024

    @iiwolf

    This was driving me nuts and I couldn't find a thread on it! Can confirm that downgrading works

  5. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on May 31, 2024
  6. eleanorjboyd commented on Jun 3, 2024

    @eleanorjboyd
    Contributor

    Hello! We are aware of this issue and actively working to get a fix- apologies for the delay this ended up being a more complex fix than anticipated. Thanks

  7. DetachHead commented on Jul 23, 2024

    @DetachHead
    Author

    it seems like a recent update has changed the behavior. now instead of raising KeyError, it re-runs but it incorrectly attempts to run all tests in your project instead of the specific test you're trying to rerun

  8. golgor commented on Jul 23, 2024

    @golgor

    it seems like a recent update has changed the behavior. now instead of raising KeyError, it re-runs but it incorrectly attempts to run all tests in your project instead of the specific test you're trying to rerun

    I can confirm this. It is very annoying. 😞

  9. lanshenghai commented on Aug 14, 2024

    @lanshenghai

    Not fixed until now?

  10. 1 remaining item

  11. DetachHead commented on Sep 19, 2024

    @DetachHead
    Author

    Eleanor Boyd (@eleanorjboyd) it's still broken, it still attempts to re-run every test in the project instead of whatever test(s) were selected as i mentioned here. can this issue be re-opened please? (it doesn't let me re-open it myself)

    or would you rather i raise a new issue as the behavior has changed?

  12. paul-voelker commented on Sep 20, 2024

    @paul-voelker

    Eleanor Boyd (@eleanorjboyd) it's still broken, it still attempts to re-run every test in the project instead of whatever test(s) were selected as i mentioned here. can this issue be re-opened please? (it doesn't let me re-open it myself)

    or would you rather i raise a new issue as the behavior has changed?

    Same for me

  13. changed the title [-]`KeyError: 'params'` error when re-running pytest test[/-] [+]re-running pytest test causes it to run all tests in the workspace[/+] on Sep 20, 2024
  14. changed the title [-]re-running pytest test causes it to run all tests in the workspace[/-] [+]re-running a pytest test causes it to run all tests in the workspace[/+] on Sep 20, 2024
  15. DetachHead commented on Nov 21, 2024

    @DetachHead
    Author

    works now, thanks!

  16. added
    needs PRReady to be worked on
    verifiedVerification succeeded
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked onverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions