Skip to content

Errors when discovering unit tests #22342

Closed as not planned
Closed as not planned
@karrtikr

Description

@karrtikr

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
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions