<commit_before>from itertools import chain

from pew._utils import invoke_pew as invoke


def test_restore(workon_home, env1):
    patterns = ['lib*/*/site.py*', 'Lib/site.py*']
    to_be_deleted = set(chain(*((workon_home / 'env1').glob(pat) for pat in patterns)))
    for site in to_be_deleted:
        site.unlink()
    result = invoke('in', 'env1', 'python', '-vc', '')
    assert 'Error' in result.err or 'fail' in result.err
    invoke('restore', 'env1')
    result = invoke('in', 'env1', 'python', '-vc', '')
    assert 'Error' not in result.err and 'fail' not in result.err
<commit_msg>Ignore FileNotFoundError in case to_be_deleted set in test_restore contains symlinks<commit_after>from itertools import chain

from pew._utils import invoke_pew as invoke


def test_restore(workon_home, env1):
    patterns = ['lib*/*/site.py*', 'Lib/site.py*']
    to_be_deleted = set(chain(*((workon_home / 'env1').glob(pat) for pat in patterns)))
    for site in to_be_deleted:
        try:
            site.unlink()
        except FileNotFoundError:
            pass
    result = invoke('in', 'env1', 'python', '-vc', '')
    assert 'Error' in result.err or 'fail' in result.err
    invoke('restore', 'env1')
    result = invoke('in', 'env1', 'python', '-vc', '')
    assert 'Error' not in result.err and 'fail' not in result.err

{'fraction_non_alphanumeric': 0.1522230595327807, 'fraction_numerical': 0.007535795026375283, 'mean_word_length': 3.547945205479452, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6399523', 'n_tokens_mistral': 433, 'n_tokens_neox': 440, 'n_words': 129}