Skip to content

Run Test and Debug Test have different PYTHONPATHs #4674

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

Closed
bfrizb opened this issue Mar 7, 2019 · 1 comment
Closed

Run Test and Debug Test have different PYTHONPATHs #4674

bfrizb opened this issue Mar 7, 2019 · 1 comment

Comments

@bfrizb
Copy link

bfrizb commented Mar 7, 2019

Environment data

  • VS Code version: 1.32.0
  • Extension version (available under the Extensions sidebar): 2019.2.5558
  • OS and version: macOS Mojave 10.14.3
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: pytest==4.3.0

Expected behaviour

Run Test and Debug Test should execute from the same directory.

Actual behaviour

Run Test and Debug Test execute from different directories.
In my case, this means that all my python unit tests pass when I use Run Test, but I encounter ModuleNotFoundError using Debug Test.

It is unclear how to change the execution directories for Debug Test, relative to the ${workspaceFolder}, or if this is even possible.

screen shot 2019-03-07 at 2 16 37 pm

^ Notice in the screenshot above that the sys.path is different for Run Test vs Debug Test.

Asides:

  • I have essentially nothing in my Global settings.json file.
  • I've reproduced this issue on Two different macOS systems.

Steps to reproduce:

  1. git clone my demo/example github project (minimum code/files): https://github.com/bfrizb/demo_repo AND git checkout the vscode-python/issues/4674 branch.
  2. Open demo_repo in VSCode
  3. Try Run Test and Debug Test to observe the difference in behavior. Here is a video demonstrating the problem.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

For Run Test

============================= test session starts ==============================
platform darwin -- Python 3.7.0, pytest-4.3.0, py-1.8.0, pluggy-0.9.0
rootdir: /Users/bfrisbie/Downloads/test_repo/solution/src/python, inifile:
collected 1 item

tests/myfile_test.py F                                                   [100%]

=================================== FAILURES ===================================
___________________________________ test_add ___________________________________

    def test_add():
    	print(sys.path)
>   	assert False
E    assert False

tests/myfile_test.py:7: AssertionError
----------------------------- Captured stdout call -----------------------------
['/Users/bfrisbie/Downloads/test_repo/solution/src/python', '/Users/bfrisbie/Downloads/test_repo/solution/src/python', '/Users/bfrisbie/Downloads/test_repo/solution/src/python/src', '/Users/bfrisbie/Downloads/test_repo/solution/src/python/test', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/bfrisbie/Library/Python/3.7/lib/python/site-packages', '/usr/local/lib/python3.7/site-packages']
- generated xml file: /var/folders/l8/518s_8n51cj0lhp_5yjc55sm0000gp/T/tmp-29170sIk8mMwTxmB4.xml -
=========================== 1 failed in 0.04 seconds ===========================

For Debug Test:

============================= test session starts ==============================
platform darwin -- Python 3.7.0, pytest-4.3.0, py-1.8.0, pluggy-0.9.0
rootdir: /Users/bfrisbie/Downloads/test_repo/solution/src/python, inifile:
collected 1 item

tests/myfile_test.py F                                                   [100%]

=================================== FAILURES ===================================
___________________________________ test_add ___________________________________

    def test_add():
    	print(sys.path)
>   	assert False
E    assert False

tests/myfile_test.py:7: AssertionError
----------------------------- Captured stdout call -----------------------------
['/Users/bfrisbie/Downloads/test_repo/solution/src/python', '/Users/bfrisbie/Downloads/test_repo/solution/src/python', '/Users/bfrisbie/Downloads/test_repo/solution/src/python/src', '/Users/bfrisbie/Downloads/test_repo/solution/src/python/test', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/bfrisbie/Library/Python/3.7/lib/python/site-packages', '/usr/local/lib/python3.7/site-packages']
- generated xml file: /var/folders/l8/518s_8n51cj0lhp_5yjc55sm0000gp/T/tmp-29170sIk8mMwTxmB4.xml -
=========================== 1 failed in 0.04 seconds ===========================
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Mar 7, 2019
@DonJayamanne
Copy link

The cause is #4300

@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Mar 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Apr 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants