Closed mshafer1 closed 1 year ago
Hypothesis, somewhere pytest is calling os.path.normcase
This looks like a bug. I am not sure how to reproduce because I do not have any access to Windows machines.
You can use a workaround for now:
from decouple import Config, RepositoryEnv
config = Config(RepositoryEnv("path-to-my-env-file"))
Also if you provide a PR, I can gladly check it out.
The workaround I've used for now is to create an empty .env file when I hit this.
PR #154 opened to fix.
Fixed
Relevant info:
Debugging information: For some reason, when I run pytest on a module (A) that depends on a module (B) that pulls in decouple,
self._caller_path()
return "c:\Users\...", but if I import decouple in my test (in A) and call it directly, search_path comes in as "C:\Users\..."The former of these causes an infinite recursion in
_find_file
sinceos.path.abspath(os.sep)
returnsC:\\
.... (equivalent to Windows, but not to string comparisons...)I could raise a PR to contribute either:
os.path.relpath
to determine that the two paths are equivalent (os.path.relpath(parent, os.path.abspath(os.sep)) != "."
) ?unfortunately, since python-decouple uses travis, I'm not sure adding a Windows run to the test suite will be easy, nor am I sure that would catch this case since I'm only seeing this when executing via
python -m pytest
...