Open adriano-di-giovanni opened 8 years ago
In the meanwhile, I found this workaround
from os.path import expanduser
def test_gitignore_global_file(File):
path = expanduser('~/.gitignore_global')
gitignore_global = File(path)
assert gitignore_global.exists
Hi, thanks for reporting.
I think there is a bug here and the behavior could be different given the undelying backend or options (like sudo).
Python does not expand ~ by default. For that matter, only shells do.
likewise by default Python will not expand '$HOME/.gitignore_global' which is valid to the shell and in many cases equivalent to the example given.
Should the File() module call both expanduser and expandvars from os.path?
Using expanduser cannot work on remote connections (ssh, docker etc). This must be done by the shell.
I had the same problem. My current workaround that works on remote connections looks like this:
import os
def test_gitignore_global_file(File, User):
gitignore_global = File(os.path.join(User().home, '.gitignore_global'))
assert gitignore_global.exists
But I think it makes the tests unneccesarily verbose. It would be nice if there was a shortcut for home-local paths.
The following test fails
This one succeeds
In order to make the test succeed I have to use
/Users/me
instead of tilde.Is it correct?