Open Andrej730 opened 6 days ago
The pytest import mode is independent from python and configured with a different option
In general its recommended to use the pytest - command to avoid python adding cwd to sys.path
The pytest import mode is independent from python and configured with a different option In general its recommended to use the pytest - command to avoid python adding cwd to sys.path
What would be the recommended way to avoid pytest
adding cwd to sys.path
?
Python 3.11, Windows 11, pytest==8.2.2
py -P -m pytest new_test.py --capture=no
C:\numpy
is present insys.path
now, thereforeimport numpy
will importnumpy
not fromC:\numpy\\build-install\\usr\\Lib\\site-packages
as it's set byPYTHONPATH
environment variable but fromC:\numpy
which is not intended since-P
is provided: https://github.com/numpy/numpy/issues/26816Example of how
-P
option usually works