Beispiel #1
0
def test_adheres_to_xdg_specification():
    with mock.patch.dict(
            os.environ,
        {'XDG_CACHE_HOME': '/tmp/fakehome'},
    ):
        ret = _get_default_directory()
        assert ret == os.path.join('/tmp/fakehome', 'pre-commit')
Beispiel #2
0
def test_uses_environment_variable_when_present():
    with mock.patch.dict(
            os.environ,
        {'PRE_COMMIT_HOME': '/tmp/pre_commit_home'},
    ):
        ret = _get_default_directory()
        assert ret == '/tmp/pre_commit_home'
Beispiel #3
0
def test_uses_environment_variable_when_present():
    with mock.patch.dict(
        os.environ, {'PRE_COMMIT_HOME': '/tmp/pre_commit_home'}
    ):
        ret = _get_default_directory()
        assert ret == '/tmp/pre_commit_home'
Beispiel #4
0
def test_get_default_directory_defaults_to_home():
    # Not we use the module level one which is not mocked
    ret = _get_default_directory()
    assert ret == os.path.join(os.path.expanduser('~/.cache'), 'pre-commit')
Beispiel #5
0
def test_get_default_directory_defaults_to_home():
    # Not we use the module level one which is not mocked
    ret = _get_default_directory()
    assert ret == os.path.join(os.path.expanduser('~'), '.pre-commit')
Beispiel #6
0
def test_get_default_directory_defaults_to_home():
    # Not we use the module level one which is not mocked
    ret = _get_default_directory()
    assert ret == os.path.join(os.environ['HOME'], '.pre-commit')
Beispiel #7
0
def test_get_default_directory_defaults_to_home():
    # Not we use the module level one which is not mocked
    ret = _get_default_directory()
    expected = os.path.realpath(os.path.expanduser('~/.cache/pre-commit'))
    assert ret == expected
Beispiel #8
0
def test_get_default_directory_defaults_to_home():
    # Not we use the module level one which is not mocked
    ret = _get_default_directory()
    assert ret == os.path.join(os.environ['HOME'], '.pre-commit')
Beispiel #9
0
def test_adheres_to_xdg_specification():
    with mock.patch.dict(
        os.environ, {'XDG_CACHE_HOME': '/tmp/fakehome'},
    ):
        ret = _get_default_directory()
        assert ret == os.path.join('/tmp/fakehome', 'pre-commit')