Esempio n. 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')
Esempio n. 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'
Esempio n. 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'
Esempio n. 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')
Esempio n. 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')
Esempio n. 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')
Esempio n. 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
Esempio n. 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')
Esempio n. 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')