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

cannot find unittest in files that contains . in its file name #22745

Closed
shelper opened this issue Jan 12, 2024 · 2 comments
Closed

cannot find unittest in files that contains . in its file name #22745

shelper opened this issue Jan 12, 2024 · 2 comments
Assignees
Labels
area-testing info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@shelper
Copy link

shelper commented Jan 12, 2024

Type: Bug

Behaviour

Cannot find unittests in files with . in it's file name

Expected vs. Actual

Expected: find tests in file named like "foo.test.py"
Actual: fail to find tests, but if change to "foo_test.py", then everything works

Steps to reproduce:

  1. create a project for python, put some tests in the project_root/tests folder called "example_test.py"
  2. configure the settings for python unittest like
"python.testing.unittestArgs": [
  "-v",
  "-s",
  "./tests",
  "-p",
  "*_test.py"
]
  1. all the tests in the tests panel show up normally
  2. now, change file name example_test.py to example.test.py and the settings above to "*.test.py", all tests are gone.
  3. also tried "*\.test.py", but no luck
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.10
  • 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


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• unittestArgs: "<placeholder>"

Extension version: 2023.22.1
VS Code version: Code 1.85.1 (0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2, 2023-12-13T09:49:37.021Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.15.137.3-microsoft-standard-WSL2

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jan 12, 2024
@shelper
Copy link
Author

shelper commented Jan 12, 2024

I dont know if this is a bug for vscode or vscode-python, so i filed issue also at microsoft/vscode#202280
will close the wrong one if figured out.

@karthiknadig
Copy link
Member

@shelper Files with "." in the name can't be used with python directly. "." causes python to treat things like submodules. This has nothing to do with python extension. unittest itself will not be able to load these files. Typically, in python you prefix/suffix files with test_ or _test. This is why it works with "_" and not with ".".

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jan 12, 2024
@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2024
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

3 participants