Skip to content

Unexpected PytestCacheWarning when passing /dev/null as config file for pytest #11502

Open
@ssbarnea

Description

@ssbarnea

While not really a serious bug, it seems confusing to get this behavior:

$ pytest --config-file=/dev/null --collect-only tests/fixtures/duplicate_names
============================================================================================= test session starts =============================================================================================
platform darwin -- Python 3.12.0, pytest-7.4.2, pluggy-1.3.0
Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type>
rootdir: /dev
configfile: null
plugins: random-order-1.1.0, mock-3.11.1, plus-0.4.1.dev2, xdist-3.3.1, libtmux-0.23.2
collected 2 items                                                                                                                                                                                             
run-last-failure: no previously failed tests, not deselecting items.

<Module test_a.py>
  <Function test>
<Module test_b.py>
  <Function test>

============================================================================================== warnings summary ===============================================================================================
../../../.asdf/installs/python/3.12.0/lib/python3.12/site-packages/_pytest/stepwise.py:56
  /Users/ssbarnea/.asdf/installs/python/3.12.0/lib/python3.12/site-packages/_pytest/stepwise.py:56: PytestCacheWarning: could not create cache path /dev/.pytest_cache/v/cache/stepwise: [Errno 1] Operation not permitted: '/dev/.pytest_cache'
    session.config.cache.set(STEPWISE_CACHE_DIR, [])

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

I wanted to disable local config on purpose for debugging some behaviors and passing /dev/null is quite a common approach. Also, I would argue that having the config file on a read-only location might happen in real life.

Is there a way to avoid this warning?

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: stepwisetopic: configrelated to config handling, argument parsing and config filetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions