Skip to content

Discovery works but execution fails with file not found error #21640

Description

Hello,

I didn't seem to have this problem before, but something seems to have gone a bit wonky this week (no changes to config on my end).
Using the vscode Testing pane, I'm seeing tests successfully discovered, but if i try to run (or debug them), they automatically fail with a

ERROR: file or directory not found: <package/module/submodule_1/submodule_2/tests/test_file.py>

Our layout is a bit interesting, but at a high level it's something like

repo\
    lib\
        package\

The terminal spawns at repo, but I have an .env file with PYTHONPATH=lib. All this seemed to have worked until say... Thursday? :) . Perhaps I had it setup wrong. In the debug output, I do see it now showing:
Recieved JSON data: [package/module/submodule_1/submodule_2/tests/test_file.py::tests_blahblah

I've never seen that Received JSON line before; i do wonder if something on the paths is getting a little messed up from the latest version? Apologies for the mediocre output trace; trying to abstract it as much as I can. Let me know what else I could do to be helpful?

I'm using v2023.12.0.

And of course running something like pytest lib\package\module\submodule_1\submodule_2\tests\test_file.py works perfectly fine from terminal!

Thanks.

Activity

  1. juandiago commented on Jul 15, 2023

    @juandiago

    I can confirm this same issue on my end with versions above 2023.8.0, had to pin the extension version to 2023.8.0 on my devcontainer.json to be able to work with the Testing panel again. Looks like a regression got introduced on releases after 2023.8.0.

    From early investigation, seems like pytest's rootdir is getting changed between the discovery phase and the run phase of the tests.

    pytest.ini

    [pytest]
    DJANGO_SETTINGS_MODULE = app.settings
    pythonpath = . src
    env =
        ENV=test
    addopts = -v --color=yes -p no:warnings
    
  2. juandiago commented on Jul 15, 2023

    @juandiago

    flagging some similar issues over here:

    #21637
    #21632

  3. changed the title [-]Execution works but discovery fails with file not found error[/-] [+]Discovery works but execution fails with file not found error[/+] on Jul 15, 2023
  4. akarev0 commented on Jul 17, 2023

    @akarev0

    juandiago downgraded extension version from 2023.12 to 2023.8 and I can verify that it works again, thanks :)

  5. eleanorjboyd commented on Jul 17, 2023

    @eleanorjboyd
    Member

    Thank you for your issue report. We are looking into this now! In the meantime, you are likely on the new testing rewrite and this is why you saw a change in behavior since we just moved to this experiment to a larger group of people receiving it. You can opt out of the rewrite as I get this fix in by setting this in your user settings: "python.experiments.optOutFrom": ["pythonTestAdapter"],. If this doesn't work let me know as this will mean it is a different issue. Thank you and I will send updates in this thread as I get a fix in.

  6. eleanorjboyd commented on Jul 17, 2023

    @eleanorjboyd
    Member

    Hello! Would people agree that #21632 has a minimal repro? I have tried this with version v2023.8.0 and it is still not working for me. Can anyone provide any ideas on what might be going wrong? Here is my minimal repro as a zip
    path_issue.zip

  7. juandiago commented on Jul 17, 2023

    @juandiago

    Eleanor Boyd (@eleanorjboyd) some more data points:

    • Disabling the pythonTestAdapter, allows me to use the Testing panel again, so it does seems related to that
    • The output I get on the console is not the same as test explorer cannot import .env #21632, I get a file-not-found error
    • Checking the pytest conf on the test logs, the rootdir changes between the detection phase & the run phase of the test, resulting(I presume) on the file-not-found error
  8. abadrinath15 commented on Jul 17, 2023

    @abadrinath15
    Author

    Eleanor Boyd (@eleanorjboyd) some more data points:

    • Disabling the pythonTestAdapter, allows me to use the Testing panel again, so it does seems related to that

    • The output I get on the console is not the same as test explorer cannot import .env #21632, I get a file-not-found error

    • Checking the pytest conf on the test logs, the rootdir changes between the detection phase & the run phase of the test, resulting(I presume) on the file-not-found error

    I just wanted to hop-in and say my experience is the same as Juan Pablo Moreno G (@juan) on points 2/3, and I notice the rootdir thing as well. I unfortunately can't test 1 / the repro until later, but, rolling back to 2023.8 did work for me as well.

  9. eleanorjboyd commented on Jul 17, 2023

    @eleanorjboyd
    Member

    Using the zip below as a minimal repro and still not seeing it (sorry!). What is listed in your settings for the pytest args? Anything else I set up incorrectly? I appreciate all the help- thanks! path_changing.zip

  10. 23 remaining items

  11. abadrinath15 commented on Sep 11, 2023

    @abadrinath15
    Author

    Aditya Badrinath (@abadrinath15) not they not, it's still there

    Oh sorry! Undoing that.

  12. akarev0 commented on Sep 11, 2023

    @akarev0

    Aditya Badrinath (@abadrinath15) yeah, look fixed, sorry :)

  13. abadrinath15 commented on Sep 11, 2023

    @abadrinath15
    Author

    Aditya Badrinath (@abadrinath15) yeah, look fixed, sorry :)

    ok!

  14. eleanorjboyd commented on Oct 6, 2023

    @eleanorjboyd
    Member

    Hi, what is the status on this? Did people try it and it wasn't fixed?

  15. abadrinath15 commented on Oct 6, 2023

    @abadrinath15
    Author

    Hi Eleanor Boyd (@eleanorjboyd)! To my understanding it was fixed and that's why I closed it.

  16. juandiago commented on Oct 20, 2023

    @juandiago

    Can confirm resolved, everything green & working

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

Metadata

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable bugtriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions