File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,11 @@ def _get_default_directory() -> str:
3030 `Store.get_default_directory` can be mocked in tests and
3131 `_get_default_directory` can be tested.
3232 """
33- return os .environ .get ('PRE_COMMIT_HOME' ) or os .path .join (
33+ ret = os .environ .get ('PRE_COMMIT_HOME' ) or os .path .join (
3434 os .environ .get ('XDG_CACHE_HOME' ) or os .path .expanduser ('~/.cache' ),
3535 'pre-commit' ,
3636 )
37+ return os .path .realpath (ret )
3738
3839
3940class Store :
Original file line number Diff line number Diff line change @@ -25,23 +25,26 @@ def test_our_session_fixture_works():
2525def test_get_default_directory_defaults_to_home ():
2626 # Not we use the module level one which is not mocked
2727 ret = _get_default_directory ()
28- assert ret == os .path .join (os .path .expanduser ('~/.cache' ), 'pre-commit' )
28+ expected = os .path .realpath (os .path .expanduser ('~/.cache/pre-commit' ))
29+ assert ret == expected
2930
3031
3132def test_adheres_to_xdg_specification ():
3233 with mock .patch .dict (
3334 os .environ , {'XDG_CACHE_HOME' : '/tmp/fakehome' },
3435 ):
3536 ret = _get_default_directory ()
36- assert ret == os .path .join ('/tmp/fakehome' , 'pre-commit' )
37+ expected = os .path .realpath ('/tmp/fakehome/pre-commit' )
38+ assert ret == expected
3739
3840
3941def test_uses_environment_variable_when_present ():
4042 with mock .patch .dict (
4143 os .environ , {'PRE_COMMIT_HOME' : '/tmp/pre_commit_home' },
4244 ):
4345 ret = _get_default_directory ()
44- assert ret == '/tmp/pre_commit_home'
46+ expected = os .path .realpath ('/tmp/pre_commit_home' )
47+ assert ret == expected
4548
4649
4750def test_store_init (store ):
You can’t perform that action at this time.
0 commit comments