Skip to content

Getting permission error with latest pytest versions 8.0.2 #12034

@pashupati123

Description

@pashupati123

Description
When attempting to run pytest with a JSON file specified as an argument (pytest <test_file.py> -T <json_file>), I encounter a permission error with pytest versions higher than 7.4.4. The error is as follows:

/auto/cafy-ott/pasverma-cafykit/cafykit/env/lib/python3.11/site-packages/pluggy/_hooks.py:501: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
/auto/cafy-ott/pasverma-cafykit/cafykit/env/lib/python3.11/site-packages/pluggy/_manager.py:119: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/auto/cafy-ott/pasverma-cafykit/cafykit/env/lib/python3.11/site-packages/_pytest/python.py:211: in pytest_collect_directory
    if pkginit.is_file():
/auto/cafy-ott/python3.11.4/lib/python3.11/pathlib.py:1267: in is_file
    return S_ISREG(self.stat().st_mode)
/auto/cafy-ott/python3.11.4/lib/python3.11/pathlib.py:1013: in stat
    return os.stat(self, follow_symlinks=follow_symlinks)
E   PermissionError: [Errno 13] Permission denied: '/lost+found/__init__.py'

This issue occurs specifically when the JSON file has read-only access with pytest version higher than 7.4.4
Steps to Reproduce:
Upgrade pytest to version 8.0.0 or higher.
Run pytest with the command pytest <test_file.py> -T <json_file> where <json_file> has read-only access.

Expected Behavior:
Pytest should be able to execute without encountering permission errors, even when the JSON file has read-only access, which is working with pytest version lower than equal to 7.4.4

Observation:
Providing an additional argument --rootdir='<non_empty_root_dir>' along with the pytest command resolves the permission error, even when the JSON file has read-only access.

pytest version : 8.0.2

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