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

python.testing.cwd ignored when discovering or running tests using unittest #11425

Closed
Ark-kun opened this issue Apr 26, 2020 · 7 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@Ark-kun
Copy link

Ark-kun commented Apr 26, 2020

The issues is similar to #8678 , but is about unittest, not pytest

Environment data

  • VS Code version: 1.44.0
  • Extension version: 2020.4.74986
  • OS and version: Windows 10 Pro 1903
  • Python version: python 3.7.4 x64
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): True
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

Set python.testing.cwd to correct directory in Workspace settings.
Try discovering tests.
The test discovery uses the provided cwd.

Actual behaviour

The test discovery ignores the provided cwd.

Output for Python in the Output panel:

Here is what I see during test discovery:
(My python.testing.cwd is set to "sdk/python" or "<workspace_root>/sdk/python").

> .../python ...\.vscode\extensions\ms-python.python-2020.4.74986\pythonFiles\pyvsc-run-isolated.py -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="*test*.py")
print("start") #Don't remove this line
for suite in suites._tests:
    for cls in suite._tests:
        try:
            for m in cls._tests:
                print(m.id())
        except:
            pass"
cwd: <workspace_root>

See how the bottom line prints a different value of cwd.

P.S. I'm seeing the above log twice every time I try discovering the tests...

@Ark-kun Ark-kun added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Apr 26, 2020
@karthiknadig
Copy link
Member

karthiknadig commented Apr 28, 2020

@Ark-kun try the latest build (2020.4.76186), we released one today. It should fix an issue with discovering and running tests. If it does not address this issue please let us know.

@karthiknadig karthiknadig self-assigned this Apr 29, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Apr 29, 2020
@yandemontreal
Copy link

Happens to me when just launching the debugger. My Launch target configuration includes a "cwd", but since version 2020.4.74986 it is ignored. Rolled back to 71113, it's working fine.

In 71113, when launching (with integrated terminal, Windows 10) it would start the terminal already in the specified cwd.

With newer versions, it opens the terminal in the workspace directory and launches the debugger.

@karthiknadig
Copy link
Member

@yandemontreal You can add a test debug configuration and add cwd there as a workaround. Add it to launch.json, and when you click debug test it will use this config.

{
    "name": "Debug Config",
    "type": "python",
    "request": "test",
    "cwd": "" // <--- Set this
}

@karthiknadig
Copy link
Member

@yandemontreal You did not mention if you had issue with pytest or unittest. We recently pushed an update that should address the cwd problem with unittest.

@yandemontreal
Copy link

yandemontreal commented May 1, 2020

@karthiknadig It is neither. It's just on a plain old "launch" request. And I've always specified cwd. It just stopped working.

        {
            "name": "Python: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "args": [...],
            "console": "integratedTerminal"
        }

@karthiknadig
Copy link
Member

@yandemontreal created an issue on the debugger on your behalf. Please track it there.

@karthiknadig
Copy link
Member

Closing this, since the original issue with unittest should be addressed in the latest release. @Ark-kun Please let me know if this is not addressed by 2020.4.76186

@ghost ghost removed the triage label May 1, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants