# Path: pre_commit/commands/clean.py
# def clean(store: Store) -> int:
#     legacy_path = os.path.expanduser('~/.pre-commit')
#     for directory in (store.directory, legacy_path):
#         if os.path.exists(directory):
#             rmtree(directory)
#             output.write_line(f'Cleaned {directory}.')
#     return 0


import os.path
import pytest
from unittest import mock
from pre_commit.commands.clean import clean
from __future__ import annotations





@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)

# Path: pre_commit/commands/clean.py
# def clean(store: Store) -> int:
#     legacy_path = os.path.expanduser('~/.pre-commit')
#     for directory in (store.directory, legacy_path):
#         if os.path.exists(directory):
#             rmtree(directory)
#             output.write_line(f'Cleaned {directory}.')
#     return 0


# Path: tests/commands/clean_test.py
import os.path
import pytest
from unittest import mock
from pre_commit.commands.clean import clean

from __future__ import annotations





@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)