Skip to content

Pytest test discovery failing when pytestArgs contains filepaths #18562

@cdce8p

Description

@cdce8p

Issue Type: Bug

At the moment, files are filtered from pytestArgs before test discovery is run. This is unexpected for a user and could lead to issues:

  1. Not all tests will be found
    Given a file tree and pytestArgs
tests/
├── dir
│   └── test_b.py
├── helpers
│   └── test_c.py
└── test_a.py
    "python.testing.pytestArgs": [
        "tests/dir",
        "tests/helpers/test_c.py",
    ],

tests/helpers/test_c.py would be filtered and only tests inside of tests/dir would be discovered.

  1. pytest discovery failing completely
    In large projects it's possible that different test subfolders require different dependencies via conftest.py. Not all of them might be installed. If the desire was to only discover tests in tests/dir/test_b.py, having that argument filtered would mean that discovery is run from root and thus all conftest.py files are loaded. If the test is inside a subfolder, it's possible to work around it by removing the filename. However that doesn't work for tests inside the root test directory.

Extension version: 2022.0.1814523869
VS Code version: Code 1.64.2 (f80445acd5a3dadef24aa209168452a3d97cc326, 2022-02-09T22:00:58.347Z)
OS version: Darwin x64 19.6.0
Restricted Mode: No

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-testingbugIssue identified by VS Code Team member as probable bugverification-neededVerification of issue is requestedverifiedVerification succeeded

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions