GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `testpaths = A A/B` doesn't test folder A (used to work in v7.4.4) · Issue #12605 · pytest-dev/pytest

testpaths = A A/B doesn't test folder A (used to work in v7.4.4) #12605

New issue
Copy link
New issue
Copy link
Open
Open
testpaths = A A/B doesn't test folder A (used to work in v7.4.4)#12605
Copy link
Labels
topic: collectionrelated to the collection phasetype: regressionindicates a problem that was introduced in a release which was working previously

Description

@Famlam
Famlam
opened on Jul 13, 2024
Issue body actions

In the project Osmose we have the following configuration:

[pytest]
# Note that some files are excluded in "conftest.py"
norecursedirs = *
testpaths = . plugins plugins/tests modules analysers
python_files = *.py
python_classes = Test
python_functions = test test*

# Suppress warnings from shapely.affinity, which are fixed on a latter version
filterwarnings =
  ignore:.*invalid escape sequence.*:DeprecationWarning

Note especially the testpaths = . plugins plugins/tests modules analysers line together with norecursedirs = *

In version 7.4.4 this meant:

  • Check the main folder
  • Check the plugins folder
  • Check the plugins/tests folder
  • Check the modules folder
  • Check the analysers folder

In version 8.2.2 however this skips the files in the plugins folder, e.g.

  • Check the main folder
  • Check the plugins folder
  • Check the plugins/tests folder
  • Check the modules folder
  • Check the analysers folder

The header line when running the pytest command still mentions testpaths: ., plugins, plugins/tests, modules, analysers

============================= test session starts ==============================
platform linux -- Python 3.11.[9](https://github.com/osm-fr/osmose-backend/actions/runs/9844396084/job/27177682389#step:10:10), pytest-8.2.2, pluggy-1.5.0
rootdir: /__w/osmose-backend/osmose-backend
configfile: pytest.ini
testpaths: ., plugins, plugins/tests, modules, analysers
plugins: pylama-8.4.1
collected 68 items

I therefore think this change in behavior is likely not intended.

The directory structure, simplified, is:

root
|- analysers
| |- subfolders (to skip)
|- modules
| |- subfolders (to skip)
|- other folders
| |- subfolders (to skip)
|- plugins
| |- tests
| |- other subfolders (to skip)

Environment:

  • Pytest: 8.2.2 (also confirmed to fail on 8.0.2)
  • Operating System: Debian GNU/Linux 11 (bullseye)
pip list
Package                   Version
------------------------- ---------------
antlr4-python3-runtime    4.13.1
anyio                     4.4.0
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.3.0
asttokens                 2.4.1
async-lru                 2.0.4
attrs                     23.2.0
Babel                     2.15.0
beautifulsoup4            4.12.3
bleach                    6.1.0
branca                    0.7.2
certifi                   2024.7.4
cffi                      1.16.0
charset-normalizer        3.3.2
click                     8.1.7
comm                      0.2.2
debugpy                   1.8.2
decorator                 5.1.1
defusedxml                0.7.1
exceptiongroup            1.2.2
executing                 2.0.1
fastjsonschema            2.20.0
fqdn                      1.5.1
future                    1.0.0
geojson                   3.1.0
h11                       0.14.0
httpcore                  1.0.5
httpx                     0.27.0
idna                      3.7
importlib-metadata        8.0.0
iniconfig                 2.0.0
ipykernel                 6.29.5
ipyleaflet                0.19.1
ipython                   8.18.1
ipywidgets                8.1.3
isoduration               20.11.0
jedi                      0.19.1
jinja2                    3.1.4
json5                     0.9.25
jsonpointer               3.0.0
jsonschema                4.23.0
jsonschema-specifications 2023.12.1
jupyter-client            8.6.2
jupyter-core              5.7.2
jupyter-events            0.10.0
jupyter-leaflet           0.19.1
jupyter-lsp               2.2.5
jupyter-server            2.14.2
jupyter-server-terminals  0.5.3
jupyterlab                4.2.3
jupyterlab-pygments       0.3.0
jupyterlab-server         2.27.2
jupyterlab-widgets        3.0.11
libarchive                0.4.8
lockfile                  0.12.2
mapbox-vector-tile        1.2.1
MarkupSafe                2.1.5
matplotlib-inline         0.1.7
mccabe                    0.7.0
mistune                   3.0.2
mypy                      1.10.1
mypy-extensions           1.0.0
nbclient                  0.10.0
nbconvert                 7.16.4
nbformat                  5.10.4
nest-asyncio              1.6.0
nose2                     0.15.1
notebook                  7.2.1
notebook-shim             0.2.4
numpy                     2.0.0
osmium                    3.7.0
overrides                 7.7.0
packaging                 24.1
pandas                    2.2.2
pandocfilters             1.5.1
parso                     0.8.4
pexpect                   4.9.0
pip                       20.3.4
pkg-resources             0.0.0
platformdirs              4.2.2
pluggy                    1.5.0
polib                     1.2.0
prometheus-client         0.20.0
prompt-toolkit            3.0.47
protobuf                  3.20.3
psutil                    6.0.0
psycopg2-binary           2.9.9
ptyprocess                0.7.0
pure-eval                 0.2.2
pyclipper                 1.3.0.post5
pycodestyle               2.12.0
pycparser                 2.22
pydocstyle                6.3.0
pyflakes                  3.2.0
pygments                  2.18.0
PyKOpeningHours           1.6.0
pylama                    8.4.1
pyproj                    3.6.1
pytest                    8.2.2
python-dateutil           2.9.0.post0
python-json-logger        2.0.7
pytz                      2024.1
PyYAML                    6.0.1
pyzmq                     26.0.3
referencing               0.35.1
regex                     2024.5.15
requests                  2.32.3
rfc3339-validator         0.1.4
rfc3986-validator         0.1.1
rpds-py                   0.19.0
scipy                     1.13.1
Send2Trash                1.8.3
sentry-sdk                2.9.0
setuptools                44.1.1
shapely                   2.0.5
six                       1.16.0
sniffio                   1.3.1
snowballstemmer           2.2.0
soupsieve                 2.5
stack-data                0.6.3
termcolor                 2.4.0
terminado                 0.18.1
tiletanic                 1.1.0
tinycss2                  1.3.0
tomli                     2.0.1
tornado                   6.4.1
traitlets                 5.14.3
traittypes                0.2.1
transporthours            0.0.4
types-certifi             2021.10.8.3
types-pkg-resources       0.1.3
types-python-dateutil     2.9.0.20240316
types-requests            2.32.0.20240712
types-termcolor           1.1.6.2
types-toml                0.10.8.20240310
typing-extensions         4.12.2
tzdata                    2024.1
Unidecode                 1.3.8
uri-template              1.3.0
urllib3                   2.2.2
vt2geojson                0.2.1
wcwidth                   0.2.13
webcolors                 24.6.0
webencodings              0.5.1
websocket-client          1.8.0
wheel                     0.34.2
widgetsnbextension        4.0.11
xmltodict                 0.13.0
xyzservices               2024.6.0
zipp                      3.19.2

Note that if I remove either plugins or plugins/tests from testpaths, everything behaves as expected (except that the removed directory isn't checked of course)

Related issue: osmose-qa/osmose-backend#2266

Activity

Next
  1. RonnyPfannschmidt commented on Jul 14, 2024

    @RonnyPfannschmidt
    RonnyPfannschmidt
    on Jul 14, 2024
    Member
    More actions

    @bluetech my first rough idea for verification would be that the culling of test-path parent directories for the Directory collection may be overzealous if one of the parent folders is path of the testdirs

    it should be gracefully handled, and perhaps warn that the extra subdir entry is of no consequence
    we also should note that completely disabling recursion is currently a edge case we haven't worked with

  2. Zac-HD
    added
    topic: collectionrelated to the collection phase
    type: regressionindicates a problem that was introduced in a release which was working previously
    on Jul 21, 2024
  3. potiuk
    added 2 commits that reference this issue on Aug 15, 2024

    Mark TestSparkKubernetes test as db test

    65075df
  4. potiuk commented on Aug 15, 2024

    @potiuk
    potiuk
    on Aug 15, 2024
    More actions

    We stumbled upon the same issue in Airflow - we have a way to make selective checks (based on what has changed in the incoming commit we select folders to run tests on (but we want to recursively search them).

    In some cases the selective checks resulted in (roughly):

    pytest tests/providers tests/providers/amazon tests/providers/google
    

    In pytest 7.* that collected all tests/providers tests recursively (including many other subfolders of tests/providers - including amazon, google tests recursively as well). However with Pytest 8.3.2 that we have currently this only collects "amazon" and "google".

    I downgraded pytest and checked that (as expected) the behaviour changed in Pytest 8.0.0.

    I workarounded it in apache/airflow#41499 - (I remove provider subfolders from the list) when I see I have the parent "tests/providers" also added), however, I think that behaviour is a bit unexpected - I guess it is a side effect of one of the changes in https://docs.pytest.org/en/stable/changelog.html#collection-changes, but it might be pretty disruptive if somoene had similar case - because it does not give an indication that only a subset of tests are run.

    Possibly restoring old behaviour should be considered if possible.

  5. vincbeck
    added a commit that references this issue on Aug 15, 2024

    Mark TestSparkKubernetes test as db test (#41500)

    666183f
  6. potiuk
    added 4 commits that reference this issue on Aug 15, 2024

    Fix Non-DB test calculation for main builds

    4b3c953

    Fix Non-DB test calculation for main builds (#41499)

    d489826

    Fix Non-DB test calculation for main builds (apache#41499)

    8a57829

    Fix Non-DB test calculation for main builds (#41499) (#41543)

    e36e521
  7. Artuz37
    added 2 commits that reference this issue on Aug 19, 2024

    Mark TestSparkKubernetes test as db test (apache#41500)

    1f5210a

    Fix Non-DB test calculation for main builds (apache#41499)

    da73dbb
  8. 18 remaining items

  9. bluetech commented on Nov 23, 2025

    @bluetech
    bluetech
    on Nov 23, 2025
    Member
    More actions

    @Famlam Yes, I can see why it might happen. The code in pytest 9.0 runs a simple syntactic dedup algorithm on the arguments, so given . plugins plugins/tests modules analysers it sees all the other args are nested under . so just removes them and keeps only .. The algorithm does not consider norecursedirs. TBH I didn't think about that.

    Do you mind explaining a bit why you setup things this way? It is unusual so I'd like to understand.

  10. bluetech
    reopened this on Nov 23, 2025
  11. bluetech commented on Nov 23, 2025

    @bluetech
    bluetech
    on Nov 23, 2025
    Member
    More actions

    Considering norecursedir in the algorithm is not difficult, I did it in a WIP patch here: https://github.com/bluetech/pytest/commits/collect-args-norecursedirs/.

    Even with this patch there is still a problem though, the other way around -- now tests are collected multiple times. Might be possible to fix as well with more tinkering (what's causing it are the session.isinitpath checks).

  12. Famlam commented on Dec 30, 2025

    @Famlam
    Famlam
    on Dec 30, 2025
    Author
    More actions

    Do you mind explaining a bit why you setup things this way? It is unusual so I'd like to understand.

    Apologies for the late reply! We have tests included in the root script (under .), as well as in the subfolders (example). However, we also have several directories such as .\plugins\disabled or [...]\generated which shouldn't be tested. Based on the available configuration options, the most logical way to set this up (without having a very long list of exclusions) would be to use this short inclusion list and a global stop on recursion.

    Removing norecursedirs=* altogether or setting it to some value like disabled generated for some reason results in an Error: Process completed with exit code 1. without any tests ran (not even in the main directory), using v9.0.2

  13. kosteev
    added 2 commits that reference this issue on Feb 25, 2026

    Mark TestSparkKubernetes test as db test (#41500)

    6ccd15f

    Fix Non-DB test calculation for main builds (#41499)

    a824af5
  14. ellert
    added a commit that references this issue on Mar 5, 2026

    Fix testpaths for newer pytest versions

    6a607ef
  15. blink1073
    added a commit that references this issue on Mar 5, 2026

    Fix testpaths for newer pytest versions (#343)

    26029d0
  16. kosteev
    added a commit that references this issue on May 11, 2026

    Sync v2-10-stable with v2-10-test to release python client v2.10.0 (#…

    50dc81b
  17. kosteev
    added 4 commits that reference this issue on Jul 26, 2026

    Mark TestSparkKubernetes test as db test (#41500)

    16060b0

    Fix Non-DB test calculation for main builds (#41499)

    68dd8a3

    Mark TestSparkKubernetes test as db test (#41500)

    a9bce74

    Fix Non-DB test calculation for main builds (#41499)

    ff564cb
  18. kosteev
    added 2 commits that reference this issue on Sep 2, 2026

    Mark TestSparkKubernetes test as db test (#41500)

    048308a

    Fix Non-DB test calculation for main builds (#41499)

    b62c5b4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: collectionrelated to the collection phasetype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.