Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Explorer hangs (because it is stuck at the test collection stage) after the "Python" extension is updated to v2024.22.1 #236901

Closed
nongnoochr opened this issue Dec 24, 2024 · 10 comments
Assignees
Labels
*caused-by-extension Issue identified to be caused by an extension

Comments

@nongnoochr
Copy link

nongnoochr commented Dec 24, 2024

My "Python" extension has the Auto Update set, and today (Tue December 24, 2024) around 1:30pm (GMT+7), the auto update was kicked in to install v2024.22.1 on my Macbook (Sequoia 15.2 (24C101) ) and the pytests in my project are no longer discovered (i.e. the test discovery process is never finished)

Note that I disabled all other extensions and found that the "Python" extension is the culprit here.
This issue is resolved after revert back to version v2024.22.0 by choosing the "Install Specific Version" option in the context menu

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: Version: 1.96.2 (Universal)
  • OS Version: Sequoia 15.2 (24C101)

Steps to Reproduce:

  1. Update the "Python" extension in vscode to the latest one (v2024.22.1)
  2. Open a project with multiple pytests (My project have a mixture of sync and async pytests, pytest parametrization, test class etc.)
  3. Select the Tests tab. Notice that no tests show up (or only one show up). If you inspect in the "OUTPUT" tab, you'll see that the tests never finish the test discovery phrases.
@WellingtonNico
Copy link

WellingtonNico commented Dec 24, 2024

Same problem here, there is not error logs, never ends finding tests, but in the python test logs pytest collect almost finished

this is the image of the hanging

Image

this is the logs when it collects successfully

[1m============================= test session starts ==============================�[0m
platform darwin -- Python 3.11.3, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/teste/projetos/pessoal/python/fastapi-todo-list
configfile: pytest.ini
plugins: asyncio-0.24.0, cov-6.0.0, anyio-4.7.0, xdist-3.6.1
asyncio: mode=Mode.AUTO, default_loop_scope=None
collected 1 item

<Dir fastapi-todo-list>
  <Package tests>
    <Module test_first.py>
      <Function test_first_test>

�[32m========================== �[32m1 test collected�[0m�[32m in 0.01s�[0m�[32m ===========================�[0m
Starting now, all test run output will be sent to the Test Result panel, while test discovery output will be sent to the "Python" output channel instead of the "Python Test Log" channel. The "Python Test Log" channel will be deprecated within the next month. See https://github.com/microsoft/vscode-python/wiki/New-Method-for-Output-Handling-in-Python-Testing for details.

this is the log for that project that does hang when collecting

you can notice there is a log missing at the end that exists in the above log: test collected

�[1m============================= test session starts ==============================�[0m
platform darwin -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0 -- /Users/teste/projetos/pessoal/python/fastapi-todo_list/.venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/teste/projetos/pessoal/python/fastapi-todo_list
configfile: pytest.ini
plugins: asyncio-0.24.0, cov-6.0.0, anyio-4.7.0, xdist-3.6.1
asyncio: mode=Mode.AUTO, default_loop_scope=None
�[1mcollecting ... �[0mcollected 17 items

<Dir fastapi-todo_list>
  <Package tests>
    <Dir auth>
      <Module test_auth_api.py>
        <Coroutine test_signup>
        <Coroutine test_login>
        <Coroutine test_me_with_todos>
        <Coroutine test_me_without_todos>
        <Coroutine test_logout_on_get_and_post>
    <Dir main>
      <Module test_main.py>
        <Coroutine test_healthy>
    <Dir todo>
      <Module test_todo_api.py>
        <Coroutine test_get_user_todos_security>
        <Coroutine test_get_user_todos>
        <Coroutine test_create_todo_security>
        <Coroutine test_create_todo>
        <Coroutine test_create_todo_title_validation>
        <Coroutine test_update_todo_security>
        <Coroutine test_update_todo>
        <Coroutine test_delete_todo_security>
        <Coroutine test_delete_todo>
        <Coroutine test_count_user_todos>
        <Coroutine test_get_todos_full>

I tried both with same python version and it does not work as well, both projects have the same dependencies, the only difference are the tests. In my Django projects the tests stopped working too, they were working just fine yesterday(2024/12/23), the same problem occurs, hangs when collecting the tests.

what I already tried:

  • fresh install
  • new user with totally fresh install and only the needed extensions(I thought it was gonna work)
  • different python versions

I'm currently using macOS, latest version with m3 pro chip, I also made sure I'm using the correct build version for apple silicon.

update

inside devcontainer it finds the tests and also run, but I was not able to debug them like yesterday, the debug menu appears, I can even set the breakpoints but the code never pauses(and yes, I'm did debug tests inside dev container before and it was working).
I have just a few extensions inside dev container, more than when I tested with fresh instalation with new user, for me it looks like something maybe related to macos

what worked

I downgraded python, and debugpy extension version, the tests were found, for all projects, but I still was not able to debug them, accidentaly I noticed it worked for a new project that I created just to test this case, so I cloned my repo into a new folder and everything worked again, so I also tried to update the python extensions again and It broke again, :(

@ryanapfel
Copy link

Also experiencing this! For me this occurred after downloading the 1.96.1 update.

@zeev-finaloop
Copy link

The same issue here

@WellingtonNico
Copy link

I suggest you guys to do what I did until we get a solution, downgrade Python extension and debugpy extension, if it doesn't work, clone you repo to a new folder and try running again, off course, also restart vscode

@RouvenG
Copy link

RouvenG commented Dec 25, 2024

Having the same issue!

I could reproduce the behavior from test discovery in a plain unit test, by isolating the part which caused the the discovery to freeze.

This unit test also freezes the same way if executed within the VSCode test executor.

#test_cause_trouble.py

def test_cause_trouble():
    import requests
    response = requests.get("http://127.0.0.1:8080")
    response.raise_for_status()

If I run the test straight from my terminal I receive requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8080): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10210a0c0>: Failed to establish a new connection: [Errno 61] Connection refused')) as expected.

Update

I just tested the code above using the VSCode Python extension version 2024.20.0 and the tests fails as expected without freezing

@janiversen
Copy link

janiversen commented Dec 25, 2024

Same here, on Mac mini M2 and Mac mini M3 both with 15.1.1

Ms-python extension v2024.22.1 fails, but reverting to v2024.22.0 and the problem is gone.

A small funny thing, after downgrading, I get a button to upgrade to v2024.22.1 (as expected), but installation still shows version 2024.22.1

Image

@akanz1
Copy link

akanz1 commented Dec 26, 2024

downgrading fixed it. see microsoft/vscode-python#24656 to stay up to date on a fix.

@gjsjohnmurray
Copy link
Contributor

/extPython

Copy link

It looks like this is caused by the Python extension. Please file the issue to the Python extension repository. Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our issue reporting guidelines for more information.

Happy Coding!

@vs-code-engineering vs-code-engineering bot added the *caused-by-extension Issue identified to be caused by an extension label Dec 26, 2024
@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 2024
@eleanorjboyd
Copy link
Member

see microsoft/vscode-python#24656 for more info- thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*caused-by-extension Issue identified to be caused by an extension
Projects
None yet
Development

No branches or pull requests

10 participants