You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Between 7.x -> 8.x there was a behavioral change with addoption (action=store) when values look like a directory paths. If such option-value pairs are provided as a list, pytest will add the value as a search-directory for tests (findpaths.get_dirs_from_args).
This causes weird behaviour, of note on Windows, if the adoption directory is say C:/Temp and you are running pytest from C:\Users\username\foo it can end up resolving a rootdir of C:/. This then triggers the searching permission bug raised in 11904, PermissionError: [WinError 5] Access is denied: 'C:\\Documents and Settings'.
The user-side fix is to pass optional arguments using option=value syntax instead of option value, but this may be an unintuitive fix based on how vague the error symptoms of this can be. As the path value will still eventually be added to the option config namespace, in many cases where intended tests are still discovered this doesn't cause a noticeable issue.
I'm not confident enough with the pytest source to submit a fix, but I'd assume you could consume your option's values before resolving search dirs? Otherwise a note in the docs on syntax requirements (key=val) for providing options with path's as values would probably also suffice?
Thanks for all your hard work, what an amazing tool and community you all have built!
Issue Checklist
a detailed description of the bug or problem you are having
output of pip list from the virtual environment you are using
Between 7.x -> 8.x there was a behavioral change with
addoption
(action=store
) when values look like a directory paths. If such option-value pairs are provided as a list, pytest will add the value as a search-directory for tests (findpaths.get_dirs_from_args).For example:
pytest tests/ --random-path C:/Temp/
This causes weird behaviour, of note on Windows, if the adoption directory is say
C:/Temp
and you are running pytest fromC:\Users\username\foo
it can end up resolving a rootdir ofC:/
. This then triggers the searching permission bug raised in 11904,PermissionError: [WinError 5] Access is denied: 'C:\\Documents and Settings'
.The user-side fix is to pass optional arguments using
option=value
syntax instead ofoption value
, but this may be an unintuitive fix based on how vague the error symptoms of this can be. As the path value will still eventually be added to the option config namespace, in many cases where intended tests are still discovered this doesn't cause a noticeable issue.I'm not confident enough with the pytest source to submit a fix, but I'd assume you could consume your option's values before resolving search dirs? Otherwise a note in the docs on syntax requirements (
key=val
) for providing options with path's as values would probably also suffice?Thanks for all your hard work, what an amazing tool and community you all have built!
Issue Checklist
pip list
from the virtual environment you are using8.3.5 & Windows 11 Pro
Somewhat difficult to provide an exact example
The text was updated successfully, but these errors were encountered: