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

Test runner unable to find test result when module path contains "py" #22120

Closed
d-tw opened this issue Sep 30, 2023 · 2 comments
Closed

Test runner unable to find test result when module path contains "py" #22120

d-tw opened this issue Sep 30, 2023 · 2 comments
Assignees
Labels
area-testing info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@d-tw
Copy link

d-tw commented Sep 30, 2023

Type: Bug

Behaviour

When running a pytest test via the testing feature, the extension is unable to report the results if the file path contains a "py" segment.

Expected vs. Actual

Say you are in a polyglot monorepo and you've organised your source tree by language:

my-app/
└── src/
    └── py/
        ├── __init__.py
        ├── main.py
        └── test_main.py

When running your tests, you will get the following error message in the output: Test result not found for <name of test>.
Renaming the directory py to something else, say python, fixes the issue.

The issue seems to be due to the function that tries to strip extra ".py" file extensions from the test ID:

.replace(/\.py[^\w\-]/g, '') // we want to get rid of the `.py` in file names

Steps to reproduce:

Using VS Code that has been configured to use pytest as the test runner.

  1. Create a file layout similar to the one above, specifically ensuring that the test file is somewhere below the py directory.

  2. Add a sample test to the test file:

def test_true():
    assert True
  1. In the Testing pane, the test should be discovered. Click to run the test. The output should reveal that despite the test running, the extension is not able to locate the output.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


venvFolders: "<placeholder>"

languageServer: "Pylance"

linting
• flake8Enabled: true

formatting
• provider: "black"

testing
• cwd: "<placeholder>"
• promptToConfigure: false
• pytestArgs: "<placeholder>"
• pytestEnabled: true

experiments
• enabled: false

Extension version: 2023.16.0
VS Code version: Code 1.82.2 (Universal) (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:59:47.790Z)
OS version: Darwin arm64 22.6.0
Modes:

System Info
Item Value
CPUs Apple M2 (8 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 2, 3, 3
Memory (System) 16.00GB (0.09GB free)
Process Argv --crash-reporter-id 11033b26-bcf4-4f48-9828-526945ff5759
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
vscaat:30438848
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
2i9eh265:30646982
showlangstatbar:30737416
962ge761:30841074
a2ce3375:30757347
ecj1e332:30736112
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
copilotsettingc:30839828
asynctok:30821568
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
dsvsc015:30845448

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Sep 30, 2023
@eleanorjboyd
Copy link
Member

Hello! Could you try this on the rewrite and send your logs? To do so, add this setting to your users settings.json "python.experiments.optInto": ["pythonTestAdapter"].

You can confirm you have the rewrite enabled by setting "python.analysis.logLevel": "Trace", in your user settings then check for Experiment 'pythonTestAdapter' is active in your python logs.

Please send the logs from the python output. You should see a log similar to Running pytest with arguments: ... can you try running this from your console( but remove -p vscode_pytest) and see if that works as expected.

@eleanorjboyd eleanorjboyd self-assigned this Oct 2, 2023
@github-actions github-actions bot added the info-needed Issue requires more information from poster label Oct 2, 2023
Copy link

github-actions bot commented Nov 2, 2023

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!

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

No branches or pull requests

2 participants