Skip to content

pytest run shows no output, gets in connection error infinite loop #22192

Closed

Description

@underyx

Note this is a bug report, but the built-in dialog for bug reports was broken.

Behaviour

Expected vs. Actual

Tests used to run when I clicked the play button in the test explorer but sometime within the last few weeks the whole integration broke.

Steps to reproduce:

  1. Trigger a pytest run in the test explorer
CleanShot.2023-10-10.at.11.36.06.mp4

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.0
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings

languageServer: "Pylance"
  "python.testing.cwd": "./server",
  "python.testing.pytestArgs": [
    "-p",
    "no:cov",
    "-p",
    "no:ddtrace",
    "-p",
    "no:ddtrace.pytest_bdd",
    "-p",
    "no:xdist"
  ],
  "python.testing.unittestEnabled": false,
  "python.testing.pytestEnabled": true,

A/B test info

vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30856252
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
showlangstatbar:30737416
962ge761:30841074
03d35959:30757346
57b77579:30736110
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
copilotsettingc:30839828
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
dsvsc015:30845448

Activity

  1. added
    feature-request
    on Oct 10, 2023
  2. added
    triage-needed
    on Oct 10, 2023
  3. eleanorjboyd commented on Oct 11, 2023

    @eleanorjboyd

    Hi! Could you send over the configuration of your machine? It seems you might be using a server? Additionally, can you copy the whole python logs and include them? It looks like you are on the new testing rewrite we are rolling out but hitting the error "Plugin error connection error". This occurs when we attempt to send the data from the subprocess we spin up back to the extension on a port. This could have happened because the socket couldn't connect or because the data couldn't be processed to be sent.

  4. added
    info-needed
    on Oct 11, 2023
  5. eleanorjboyd commented on Oct 11, 2023

    @eleanorjboyd

    also in what way was the built-in dialog for bug reports broken? Seeing it still working on my end, thanks

  6. added
    bug
    and removed
    feature-request
    on Oct 11, 2023
  7. underyx commented on Oct 11, 2023

    @underyx
    Author

    Here's all my python logs after launching vscode, waiting for tests to be discovered, and trying to run one test (triggering the infinite loop):

    2023-10-11 11:07:07.590 [info] Experiment 'python.createEnvironment.trigger' is active
    2023-10-11 11:07:07.590 [info] Experiment 'pythonPromptNewFormatterExt' is active
    2023-10-11 11:07:07.590 [info] Experiment 'pythonPromptNewToolsExt' is active
    2023-10-11 11:07:07.590 [info] Experiment 'pythonTerminalEnvVarActivation' is active
    2023-10-11 11:07:07.590 [info] Experiment 'pythonTestAdapter' is active
    2023-10-11 11:07:07.590 [info] Test server listening.
    2023-10-11 11:07:07.590 [info] Python interpreter path: ./server/.venv/bin/python
    2023-10-11 11:07:09.422 [info] > conda info --json
    2023-10-11 11:07:09.539 [info] > . ./server/.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/printEnvVariables.py
    2023-10-11 11:07:09.539 [info] shell: zsh
    2023-10-11 11:07:09.722 [info] > ~/.conda/bin/conda info --json
    2023-10-11 11:07:09.730 [info] > . ./server/.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/printEnvVariables.py
    2023-10-11 11:07:09.731 [info] shell: bash
    2023-10-11 11:07:09.744 [info] > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/printEnvVariables.py
    2023-10-11 11:07:09.744 [info] shell: zsh
    2023-10-11 11:07:09.757 [info] > ./server/.venv/bin/python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/linter.py -m mypy --python-version=3.11 ./server/semgrep_app/cloud_platform/auth/models/user_invites.py
    2023-10-11 11:07:09.757 [info] cwd: ./server
    2023-10-11 11:07:09.764 [info] > /opt/homebrew/anaconda3/bin/conda info --json
    2023-10-11 11:07:11.164 [info] Starting Pylance language server.
    2023-10-11 11:07:13.118 [info] ##########Linting Output - mypy##########
    
    2023-10-11 11:07:13.118 [info] Success: no issues found in 1 source file
    
    2023-10-11 11:07:16.313 [info] Discover tests for workspace name: app - uri: /Users/underyx/r2c/app
    2023-10-11 11:07:16.313 [info] Running discovery for pytest using the new test adapter.
    2023-10-11 11:07:16.315 [info] > ./server/.venv/bin/python -m pytest -p vscode_pytest --collect-only -p no:cov -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:xdist
    2023-10-11 11:07:16.315 [info] cwd: ./server
    2023-10-11 11:07:28.224 [info] Test server connected to a client.
    2023-10-11 11:07:28.354 [info] ResultResolver EOT received for discovery.
    2023-10-11 11:07:29.461 [info] Disposing data receiver for /Users/underyx/r2c/app and deleting UUID; pytest discovery.
    2023-10-11 11:07:36.417 [info] Server listening on port 51114
    2023-10-11 11:07:36.419 [info] Running pytest with arguments: /Users/underyx/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/vscode_pytest/run_pytest_script.py --rootdir /Users/underyx/r2c/app -p no:cov -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:xdist
    
    2023-10-11 11:07:36.419 [info] > ./server/.venv/bin/python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/vscode_pytest/run_pytest_script.py --rootdir . -p no:cov -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:xdist
    2023-10-11 11:07:36.419 [info] cwd: ./server
    

    The test logs, in copy-pastable form:

    [vscode-pytest] data: Content-Length: 430
    Content-Type: application/json
    Request-uuid: None
    
    {"cwd": "/Users/underyx/r2c/app/server", "status": "success", "result": {"/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates": {"test": "/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}
    Plugin error connection error[vscode-pytest]
    [vscode-pytest] data: Content-Length: 430
    Content-Type: application/json
    Request-uuid: None
    
    {"cwd": "/Users/underyx/r2c/app/server", "status": "success", "result": {"/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates": {"test": "/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}
    Plugin error connection error[vscode-pytest]
    [vscode-pytest] data: Content-Length: 430
    Content-Type: application/json
    
  8. removed
    info-needed
    on Oct 11, 2023
  9. eleanorjboyd commented on Oct 11, 2023

    @eleanorjboyd

    it should retry 5 times, do you think it went longer than that when running? Curious how long this loop is and if it ever ends. Also if you click the cancel button does this work to end the looping?

    What again is your machine type and setup? Are you on a remote machine or connected via ssh?

  10. added
    info-needed
    on Oct 11, 2023
  11. underyx commented on Oct 11, 2023

    @underyx
    Author

    As for my machine configuration, I'm using vscode on macOS. I'm developing locally, it's just that there's a directory called server/ in my repository.

    With the builtin bug report feature, pressing the Submit button was not doing anything for me. This might be related to API rate limits because when I was writing a title for my report, I got 'similar issues' suggestions a few times until the suggestions were replaced with a 'GitHub rate limit exceeded' message.

    The test logs loop infinitely very quickly. In the ten minutes since my previous comment these five lines have been printed at least 20,000 times.

  12. removed
    info-needed
    on Oct 11, 2023
  13. eleanorjboyd commented on Oct 11, 2023

    @eleanorjboyd

    do you have any firewall rule that might be preventing socket from connecting?

  14. 32 remaining items

  15. underyx commented on Oct 26, 2023

    @underyx
    Author

    I can confirm the fix works on my machine. Thank you!

  16. removed
    info-needed
    on Oct 26, 2023
  17. added
    verified
    author-verification-requested
    on Oct 26, 2023
  18. removed
    triage-needed
    on Oct 26, 2023
  19. jarek-webellian commented on Oct 27, 2023

    @jarek-webellian

    Indeed. I can also confirm, that the current pre-release version is working as expected. Thanks! 💯

  20. kwood commented on Oct 31, 2023

    @kwood

    I am having this issue as well and the pre-release version is an improvement (i.e., my machine no longer screams from the infinite loop) but my tests still aren't discovered. We're not modifying the environment AFAIK, maybe there are other ways to trigger this behavior?

      File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 270, in wrap_session
        session.exitstatus = doit(config, session) or 0
                             ^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 323, in _main
        config.hook.pytest_collection(session=session)
      File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
        return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
        return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 60, in _multicall
        return outcome.get_result()
               ^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result
        raise ex[1].with_traceback(ex[2])
      File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall
        res = hook_impl.function(*args)
              ^^^^^^^^^^
    2023-10-31 20:26:29.729 [error] ^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 334, in pytest_collection
        session.perform_collect()
    
    2023-10-31 20:26:29.729 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 664, in perform_collect
    
    2023-10-31 20:26:29.729 [error]     self.items.extend(self.genitems(node))
    
    2023-10-31 20:26:29.729 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 831, in genitems
    
    2023-10-31 20:26:29.729 [error]     rep = collect_one_node(node)
              ^^^^^^^^^^
    2023-10-31 20:26:29.729 [error] ^^^^^^^^^^^^
    
    2023-10-31 20:26:29.729 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/runner.py", line 538, in collect_one_node
    
    2023-10-31 20:26:29.730 [error]     rep: CollectReport = ihook.pytest_make_collect_report(collector=collector)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.730 [error] ^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
        return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
    
    2023-10-31 20:26:29.730 [error]            ^^^^^^^^^^^^^
    2023-10-31 20:26:29.730 [error] ^^^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.730 [error] ^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.730 [error] ^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
    
    2023-10-31 20:26:29.730 [error]     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
    
    2023-10-31 20:26:29.730 [error]            ^^^^^^^
    2023-10-31 20:26:29.730 [error] ^^^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.730 [error] ^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.730 [error] ^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 55, in _multicall
    
    2023-10-31 20:26:29.730 [error]     gen.send(outcome)
    
    2023-10-31 20:26:29.730 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 796, in pytest_make_collect_report
    
    2023-10-31 20:26:29.730 [error]     out, err = self.read_global_capture()
              
    2023-10-31 20:26:29.730 [error]      ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 718, in read_global_capture
        return self._global_capturing.readouterr()
      
    2023-10-31 20:26:29.730 [error]          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 623, in readouterr
    
    2023-10-31 20:26:29.731 [error]     out = self.out.snap() if self.out else ""
              ^^^^^^^^
    2023-10-31 20:26:29.731 [error] ^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 482, in snap
        res = self.tmpfile.read()
              ^^^^^^^^^^^^^^^^^^^
    FileNotFoundError: [Errno 2] No such file or directory
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 290, in wrap_session
        config.notify_exception(excinfo, config.option)
      File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1094, in notify_exception
        res = self.hook.pytest_internalerror(excrepr=excrepr, excinfo=excinfo)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
        return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
        return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.731 [error] ^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 60, in _multicall
        return outcome.get_result()
    
    2023-10-31 20:26:29.731 [error]            ^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result
    
    2023-10-31 20:26:29.731 [error]     raise ex[1].with_traceback(ex[2])
      File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall
    
    2023-10-31 20:26:29.731 [error]     res = hook_impl.function(*args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 826, in pytest_internalerror
    
    2023-10-31 20:26:29.732 [error]     self.stop_global_capturing()
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 693, in stop_global_capturing
        self._global_capturing.pop_outerr_to_orig()
    
    2023-10-31 20:26:29.732 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 579, in pop_outerr_to_orig
        out, err = self.readouterr()
                   ^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 623, in readouterr
    
    2023-10-31 20:26:29.732 [error]     out = self.out.snap() if self.out else ""
              ^^
    2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 482, in snap
    
    2023-10-31 20:26:29.732 [error]     res = self.tmpfile.read()
              ^^^^^^^^^
    2023-10-31 20:26:29.732 [error] ^^^^^^^^^^
    FileNotFoundError: [Errno 2] No such file or directory
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
    
    2023-10-31 20:26:29.732 [error]   File "<frozen runpy>", line 88, in _run_code
      File "/usr/local/lib/python3.11/site-packages/pytest/__main__.py", line 5, in <module>
        raise SystemExit(pytest.console_main())
                         ^
    2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 190, in console_main
    
    2023-10-31 20:26:29.732 [error]     code = main()
               ^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 167, in main
    
    2023-10-31 20:26:29.732 [error]     ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
              
    2023-10-31 20:26:29.732 [error]                       ^^^^^^^^
    2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
    
    2023-10-31 20:26:29.732 [error]     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
              
    2023-10-31 20:26:29.732 [error]  ^^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
    
    2023-10-31 20:26:29.732 [error]     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
    
    2023-10-31 20:26:29.732 [error]            ^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 60, in _multicall
    
    2023-10-31 20:26:29.732 [error]     return outcome.get_result()
               ^^^^^^
    2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result
    
    2023-10-31 20:26:29.732 [error]     raise ex[1].with_traceback(ex[2])
      File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall
    
    2023-10-31 20:26:29.733 [error]     res = hook_impl.function(*args)
              ^^^
    2023-10-31 20:26:29.733 [error] ^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 317, in pytest_cmdline_main
    
    2023-10-31 20:26:29.733 [error]     return wrap_session(config, _main)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
    2023-10-31 20:26:29.733 [error] ^
      File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 312, in wrap_session
    
    2023-10-31 20:26:29.733 [error]     config._ensure_unconfigure()
      File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1048, in _ensure_unconfigure
    
    2023-10-31 20:26:29.733 [error]     fin()
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 693, in stop_global_capturing
    
    2023-10-31 20:26:29.733 [error]     self._global_capturing.pop_outerr_to_orig()
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 579, in pop_outerr_to_orig
    
    2023-10-31 20:26:29.733 [error]     out, err = self.readouterr()
           
    2023-10-31 20:26:29.733 [error]         ^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 623, in readouterr
    
    2023-10-31 20:26:29.733 [error]     out = self.out.snap() if self.out else ""
              ^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 482, in snap
    
    2023-10-31 20:26:29.733 [error]     res = self.tmpfile.read()
              
    2023-10-31 20:26:29.733 [error] ^^^^^^^^^^^^^^^^^^^
    FileNotFoundError: [Errno 2] No such file or directory```
    
  21. eleanorjboyd commented on Nov 1, 2023

    @eleanorjboyd

    Kevin Wood (@kwood), could you send over a minimal repro of your setup? The logs are not giving a ton of insight to help me determine the problem. A minimal repro is just a small example that causes the same bug you see. If I am able to repro it myself that would help me determine the issue- thanks!

  22. locked as resolved and limited conversation to collaborators on Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingauthor-verification-requestedbugverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions