Skip to content

When both a directory and a file are passed on the CLI, only the file is run #13494

Closed as duplicate of#12083
@JelleZijlstra

Description

@JelleZijlstra

When the command-line args include both a directory with test files and a specific test file in that directory, pytest runs only the file and not the other files in that directory.

As an example:

$ pytest --collect-only pycroscope/ pycroscope/test_analysis_lib.py 
================================================================================================= test session starts =================================================================================================
platform darwin -- Python 3.12.2, pytest-8.4.0, pluggy-1.5.0
rootdir: /Users/jelle/py/pycroscope
configfile: pyproject.toml
collected 3 items                                                                                                                                                                                                     

<Dir pycroscope>
  <Package pycroscope>
    <Module test_analysis_lib.py>
      <Function test_get_indentation>
      <Function test_get_line_range_for_node>
      <Function test_object_from_string>

============================================================================================= 3 tests collected in 0.10s ==============================================================================================
$ pytest --collect-only pycroscope/
================================================================================================= test session starts =================================================================================================
platform darwin -- Python 3.12.2, pytest-8.4.0, pluggy-1.5.0
rootdir: /Users/jelle/py/pycroscope
configfile: pyproject.toml
collected 1026 items / 3 skipped                                                                                                                                                                                      

This is dangerous because it can lead us to silently skip running some tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions