<commit_before>"""
Test secure deletion utilities in securedrop/rm.py
"""
import os

import pytest

import rm


def test_secure_delete_capability(config):
    assert rm.check_secure_delete_capability() is True

    path = os.environ["PATH"]
    try:
        os.environ["PATH"] = "{}:{}".format("/bin", config.TEMP_DIR)
        assert rm.check_secure_delete_capability() is False
        fakeshred = os.path.join(config.TEMP_DIR, "shred")
        with open(fakeshred, "w") as f:
            f.write("#!/bin/bash\nexit1\n")
        os.chmod(fakeshred, 0o700)
        assert rm.check_secure_delete_capability() is False
    finally:
        os.environ["PATH"] = path
<commit_msg>Fixes #5601 test_rm failure on Focal<commit_after>"""
Test secure deletion utilities in securedrop/rm.py
"""
import os

import pytest

import rm


def test_secure_delete_capability(config):
    assert rm.check_secure_delete_capability() is True

    path = os.environ["PATH"]
    try:
        os.environ["PATH"] = "{}:{}".format("/sbin", config.TEMP_DIR)
        assert rm.check_secure_delete_capability() is False
        fakeshred = os.path.join(config.TEMP_DIR, "shred")
        with open(fakeshred, "w") as f:
            f.write("#!/bin/bash\nexit1\n")
        os.chmod(fakeshred, 0o700)
        assert rm.check_secure_delete_capability() is False
    finally:
        os.environ["PATH"] = path

{'fraction_non_alphanumeric': 0.12863372093023256, 'fraction_numerical': 0.010174418604651164, 'mean_word_length': 3.198170731707317, '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': '3367514', 'n_tokens_mistral': 477, 'n_tokens_neox': 470, 'n_words': 99}