vscode-python-test-adapter icon indicating copy to clipboard operation
vscode-python-test-adapter copied to clipboard

multilevel inheritance from unittest.TestCase in Test Explorer open file error by clicking the test case right button.

Open jxliaocb opened this issue 6 years ago • 4 comments

Issue Type: Bug

Error running command test-explorer.show-source: cannot open file:///home/user/study_docker/myPY_test/test/BaseTestCase.py. Detail: Unable to read file (Error: File not found (/home/user/study_docker/myPY_test/test/BaseTestCase.py)). This is likely caused by the extension that contributes test-explorer.show-source.

Extension version: 0.3.16 VS Code version: Code 1.41.1 (26076a4de974ead31f97692a0d32f90d735645c0, 2019-12-18T15:04:31.999Z) OS version: Linux x64 4.15.0-72-generic

System Info
Item Value
CPUs Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz (4 x 2394)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: unavailable_off
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 1, 1, 1
Memory (System) 8.38GB (0.71GB free)
Process Argv --no-sandbox
Screen Reader no
VM 100%

jxliaocb avatar Jan 28 '20 09:01 jxliaocb

@jxliaocb Thank you for the issue! Do you mind providing a test example to reproduce this error? Also, what python version are you using?

kondratyev-nv avatar Jan 28 '20 10:01 kondratyev-nv

myPY_test.tar.gz python version: Python 2.7.12

jxliaocb avatar Jan 28 '20 10:01 jxliaocb

I just try Python 3.5.2 64-bit that has the same issue.

jxliaocb avatar Jan 28 '20 10:01 jxliaocb

It looks like for some reason unittest discovers tests not only from start directory (-s argument) but also from the current working directory. This causes the extension to incorrectly detect file paths for tests. The discovery behavior is the same for command-line execution python -m unittest discover -v -s "./test" -p "*Test*.py".

kondratyev-nv avatar Jan 28 '20 13:01 kondratyev-nv