1
0
Fork 0

Adding upstream version 2.2.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 21:10:22 +01:00
parent 18c908e4f3
commit c0d06915b7
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
199 changed files with 14930 additions and 0 deletions

View file

@ -0,0 +1,33 @@
import os.path
from unittest import mock
import pytest
from pre_commit.commands.clean import clean
@pytest.fixture(autouse=True)
def fake_old_dir(tempdir_factory):
fake_old_dir = tempdir_factory.get()
def _expanduser(path, *args, **kwargs):
assert path == '~/.pre-commit'
return fake_old_dir
with mock.patch.object(os.path, 'expanduser', side_effect=_expanduser):
yield fake_old_dir
def test_clean(store, fake_old_dir):
assert os.path.exists(fake_old_dir)
assert os.path.exists(store.directory)
clean(store)
assert not os.path.exists(fake_old_dir)
assert not os.path.exists(store.directory)
def test_clean_idempotent(store):
clean(store)
assert not os.path.exists(store.directory)
clean(store)
assert not os.path.exists(store.directory)