Skip to content

Pytest - Run test from test explorer fail with uppercase test folder name #6410

@AlexWang-516

Description

@AlexWang-516

Environment data

  • VS Code version: 1.35.1
  • Extension version (available under the Extensions sidebar): 2019.6.22090
  • OS and version: Windows 10 Home Edition
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.8
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): global python 3.6.8
  • Relevant/affected Python packages and their versions: pytest 4.6.3
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): Jedi

Expected behaviour

Test file could be run from test explorer in activity bar.

Actual behaviour

Test file could not run from test explorer in activity bar.

CodeLens adornments disappear from the test file.

Steps to reproduce:

  1. enable pytest from D:\projectRoot.vscode\setting.json as following:
{
    "python.testing.unittestEnabled": false,
    "python.testing.nosetestsEnabled": false,
    "python.testing.pytestEnabled": true,
    "python.testing.pytestArgs": [
        "Test"
    ]
}
  1. project folder structure is as following:
D:\projectRoot\
    .vscode\
    SRC\
        src.py
    Test\
        __init__.py
        test_src.py
  1. Run Test file from test explorer in activity bar

Logs

Python Test Log say that:

============================= test session starts =============================
platform win32 -- Python 3.6.8, pytest-4.6.3, py-1.5.2, pluggy-0.12.0
rootdir: d:\projectRoot
collected 0 items / 1 errors

=================================== ERRORS ====================================
______________________ ERROR collecting test/test_src.py ______________________
ImportError while importing test module 'd:\projectRoot\test\test_src.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
ModuleNotFoundError: No module named 'test.test_src'
...

Additional Information

All the setting work for the vscode-python for previous release (2019.5.18875).

When I change the folder name containing the test file from Test to test, with python.testing.pytestArgs setting in setting.json to ["test"], test file could be run from test explorer. However, codeLens adornments still disappear.

It seems for the current release, vscode-python change the uppercase letter for folder name to lowercase before they import the test module. This change to letter case cause the problem.

Metadata

Metadata

Assignees

Labels

area-testingbugIssue identified by VS Code Team member as probable bugregressionBug didn't exist in a previous release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions