Skip to content

pytest tests are not properly displayed if test name contains upper letters #77916

@Galileo-Galilei

Description

@Galileo-Galilei

Hello,

I've encountered a little bug recently in the "Tests" tab. I am not 100% sure that the bug is related to vscode or to the python extension. see below

Environment:

  • VSCode Version: 1.34.0
  • OS Version: Windows_NT x64 6.1.7601
  • Python extension version : 2019.6.24221
  • settings.json :
{
    "python.testing.pytestArgs": [
        "tests"
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.nosetestsEnabled": false,
    "python.testing.pytestEnabled": true
}

Bug :
When a test file contains an upper letter, it is not displayed properly in the test tab. After running if passed or failed, it is displayed with a "grey question mark".

Steps to Reproduce:

  1. Create an empty project (note : use a conda environment where pytest is installed)
  2. Create a "tests" folder
    2.1 Create a test_working.py file
 import pytest

def test_this_one_works():
    assert 1==1

2.2 Create a test_NotWorking.py file with the same code

 import pytest

def test_this_one_works():
    assert 1==1
  1. In the Test tab of vscode, run Discover Tests
    If everything ran properly, you should see the following architecture :
    -(?) tests

    • (?) test_notworking.py (with lower case!!!)
      • (?) test_this_one_does_not_work
    • (?) test_working.py
      • (?) test_this_one_works
  2. In the Test tab of vscode, run Run All Tests.
    Now I have :
    -(green tick ok) tests

    • (?) test_notworking.py <- BUG - EXPECTED BEHAVIOUR : should have a green tick and have name in upper case
      • (?) test_this_one_does_not_work <- BUG - EXPECTED BEHAVIOUR : should have a green tick and have name in upper case
    • (green tick ok) test_working.py (with lower case!!!)
      • (green tick ok) test_this_one_works

Remarks :

  • the tests seem to be ran whatever is displayed (the bug only concerns the user interface) : indeed in the bottom line (where my python version and my environment are shown), I see an icon "two tests passed".
  • when i run pytest tests in the command line, everything is fine.

Conclusion :
This bugs is not critical at all since it only concerns te UI, but in my old projects I can't see the tests in the UI (while it used to work perfectly fine few weeks ago). I definitely do not want to change the names of the scripts (the tests scripts are a mirror of the scripts names of my project).

Any hope this would be easy to fix?

Many thanks for reading and any further help !
Galileo

EDIT : I reposted this question on the vscode python repo which is where it belongs. Thanks for the answer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    *caused-by-extensionIssue identified to be caused by an extension

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions