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

Pytest. Rerun code in debug ignores launch.json config #418

Closed
slavanorm opened this issue Jul 31, 2024 · 6 comments
Closed

Pytest. Rerun code in debug ignores launch.json config #418

slavanorm opened this issue Jul 31, 2024 · 6 comments
Assignees
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@slavanorm
Copy link

slavanorm commented Jul 31, 2024

Hello. Thanks for your work.

I experienced this bug when i had some customization for "debug tests" configuration in launch.json file.
Debug works, using customized cwd in launch.json, while it fails not finding cwd related imports when I click rerun.

After looking into project configuration, I should apologize in advance if this issue doesnt belong here,
as my launch.json uses type:python instead of recommended type:debugpy.
unfortunately, the same code is not capable to debug with debugpy at all.
maybe it requires different issue created?

Project organization:
root/
pyproject.toml (this should configure rootdir for pytest. it fails on rerun.)
src/
...
tests/
...

launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Streamlit debug",
            "type": "python",
            "request": "launch",
            "module": "streamlit",
            "args": [
                "run",
                "${workspaceFolder}/src/main.py"
            ],
            "justMyCode": true,
            "console": "internalConsole",
            "envFile": "${workspaceFolder}/.env"
        },
        {
            "name": "Debug test file",
            "type": "python",
            "request": "launch",
            "console": "internalConsole",
            "purpose": [
                "debug-test"
            ],
            "env": {
                "_PYTEST_RAISE": "1",
                "PYTEST_ADDOPTS": "--no-cov"
            },
            "program": "${file}",
            "justMyCode": true,
        },
    ]
}

versions:
python debugger extension: v2024.6.0
pytest:8.2.0
vscode:
Version: 1.88.1 (user setup)
Commit: e170252f762678dec6ca2cc69aba1570769a5d39
Date: 2024-04-10T17:41:02.734Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.19045
WSL on Win10

@paulacamargo25
Copy link
Contributor

Thanks @slavanorm for your bug report, there is a know error for the reload behaviour in tests here. What I can help you with is to see the error when using type: debugpy. Can you share your Python Debugger Output Logs or the error that you are getting?

@paulacamargo25 paulacamargo25 added the info-needed Issue requires more information from poster label Aug 1, 2024
@slavanorm
Copy link
Author

I couldn't manage to make tests work with debugpy at all.
Is it possible?

@paulacamargo25
Copy link
Contributor

Yes, it should work for testing, Can you share your Python Debugger Output Logs or the error that you are getting?

@slavanorm
Copy link
Author

unfortunately i dont have access to that code anymore.

i guess, this bug is already documented, right? we can close this issue then?

Copy link

Hey @karthiknadig, this issue might need further attention.

@slavanorm, you can help us out by closing this issue if the problem no longer exists, or adding more information.

@slavanorm
Copy link
Author

The most important part of this issue is documented in another one. This is closed as duplicate

@slavanorm slavanorm closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants