Skip to content

VS Code unable to find test when running single unit test #3523

Closed
@ahyerman

Description

@ahyerman

Issue Type: Bug

Python: 3.6.6
Pytest: 3.8.2

When trying to run an individual test, vs code seems to fail with ERROR: file not found: <file>::<class>::<method>. It seems VS Coder can find the test since the command to run all tests works, also all tests appear to be discovered when running either all or a single test. However when running a single test I am seeing the above failure. I've tried to enforce the path to ensure the pytest.ini and rootdir are set correctly and that also fails.

Seems this working directory issue can be solved by including multiple paths in the folders option on the workspace. It'd be great if the python.unittest.cwd option could be used for pytest as well!

Repro:

workspace settings:

       "folders": [
	{
		"path": "C:\\proj"
	}
],
	"python.unitTest.pyTestArgs": [
		"--show-capture=no",
		"-ra",
		"-Wignore",
	],
	// Whether to enable or disable unit testing using pytest.
	"python.unitTest.unittestEnabled": false,
	"python.unitTest.pyTestEnabled": true,
	"python.unitTest.nosetestsEnabled": false,

folder structure:

/proj
|___/tests
|pytest.ini
|
/scenario1
|_________test_1_s1.py
|___test_2_s1.py
|
/scenario2
|_________test_1_s2.py
|_________test_2_s2.py

It seems this error only appears when trying to run or debug a single unit test, as running all tests seems to succeed.

VS Code version: Code 1.28.2 (7f3ce96ff4729c91352ae6def877e59c561f4850, 2018-10-17T00:23:51.859Z)
OS version: Windows_NT x64 10.0.17763

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (8 x 3600)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 47.79GB (29.28GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (5)
Extension Author (truncated) Version
gitlens eam 8.5.6
nbpreviewer jit 1.0.0
python ms- 2018.9.2
PowerShell ms- 1.9.0
team ms- 1.142.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-testingbugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions