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

Errors when discovering unit tests #22342

Closed
karrtikr opened this issue Oct 25, 2023 · 1 comment
Closed

Errors when discovering unit tests #22342

karrtikr opened this issue Oct 25, 2023 · 1 comment
Assignees
Labels
area-testing triage-needed Needs assignment to the proper sub-team

Comments

@karrtikr
Copy link

karrtikr commented Oct 25, 2023

Testing #22291

I see an error after step 6:
image

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

2023-10-25 11:16:49.836 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2023-10-25 11:16:49.836 [info] Experiment 'pythonTestAdapter' is active
2023-10-25 11:16:49.837 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-10-25 11:16:49.837 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-10-25 11:16:49.837 [info] Experiment 'pythonRecommendTensorboardExt' is active
2023-10-25 11:16:49.837 [info] Experiment 'pythonREPLSmartSend' is active
2023-10-25 11:16:49.837 [info] Experiment 'pythonSurveyNotification' is active
2023-10-25 11:16:49.837 [info] Default formatter is set to ms-python.black-formatter for workspace c:\Users\karraj\inc_dec_example_repo\inc_dec_example_test_suite
2023-10-25 11:16:49.837 [info] Test server listening.
2023-10-25 11:16:49.838 [info] Python interpreter path: .\.venv\Scripts\python.exe
2023-10-25 11:16:49.994 [info] > ./.venv/Scripts/activate.bat && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-insiders/extensions/ms-python.python-2023.19.12981006/pythonFiles/printEnvVariables.py
2023-10-25 11:16:49.994 [info] shell: commandPrompt
2023-10-25 11:16:55.720 [info] > ~\AppData\Local\Programs\Python\Python37\python.exe ~/.vscode-insiders/extensions/ms-python.python-2023.19.12981006/pythonFiles/printEnvVariables.py
2023-10-25 11:16:55.720 [info] shell: commandPrompt
2023-10-25 11:16:59.200 [info] Starting Pylance language server.
2023-10-25 11:17:08.802 [info] Discover tests for workspace name: inc_dec_example_test_suite - uri: c:\Users\karraj\inc_dec_example_repo\inc_dec_example_test_suite
2023-10-25 11:17:08.802 [info] Running discovery for unittest using the new test adapter.
2023-10-25 11:17:08.802 [info] Running discovery for pytest using the new test adapter.
2023-10-25 11:17:08.838 [info] > ./.venv/Scripts/activate.bat && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-insiders/extensions/ms-python.python-2023.19.12981006/pythonFiles/printEnvVariables.py
2023-10-25 11:17:08.838 [info] shell: commandPrompt
2023-10-25 11:17:09.268 [info] Discovering unittest tests with arguments: c:\Users\karraj\.vscode-insiders\extensions\ms-python.python-2023.19.12981006\pythonFiles\unittestadapter\discovery.py,--udiscovery,-v,-s,.,-p,*test*.py

2023-10-25 11:17:09.268 [info] > .\.venv\Scripts\python.exe ~\.vscode-insiders\extensions\ms-python.python-2023.19.12981006\pythonFiles\unittestadapter\discovery.py --udiscovery -v -s . -p *test*.py
2023-10-25 11:17:09.268 [info] cwd: .
2023-10-25 11:17:09.487 [info] Test server connected to a client.
2023-10-25 11:17:09.493 [error] Unittest test discovery error 
 Failed to import test module: test_parameterized
Traceback (most recent call last):
  File "C:\Users\karraj\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "C:\Users\karraj\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "c:\Users\karraj\inc_dec_example_repo\inc_dec_example_test_suite\test_parameterized.py", line 1, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'


Failed to import test module: test_wait_parameterized
Traceback (most recent call last):
  File "C:\Users\karraj\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "C:\Users\karraj\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "c:\Users\karraj\inc_dec_example_repo\inc_dec_example_test_suite\test_wait_parameterized.py", line 1, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

2023-10-25 11:17:09.495 [info] Test server connected to a client.
2023-10-25 11:17:09.495 [info] ResultResolver EOT received for discovery.

{
  "python.testing.unittestArgs": [
    "-v",
    "-s",
    ".",
    "-p",
    "*test*.py"
  ],
  "python.testing.pytestEnabled": false,
  "python.testing.unittestEnabled": true
  // "python.logging.level": 40,
  // "liveshare.diagnosticLoggingLevel": "Trace",
  // "python.testing.unittestArgs": ["-v", "-s", ".", "-p", "test_*.py"],
  // "python.testing.unittestEnabled": true
}
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 25, 2023
@eleanorjboyd
Copy link
Member

this is expected since it is just erroring on this line import pytest in test_parameterized.py. It is in a file in the workspace so even if you don't select pytest it attempts to import it during discovery and then fails.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants