<commit_before>import os
import shutil
import unittest
from approvaltests.TextDiffReporter import TextDiffReporter


class TextDiffReportertests(unittest.TestCase):
    @property
    def tmp_dir(self):
        test_dir = os.path.dirname(os.path.realpath(__file__))
        return os.path.join(test_dir, 'tmp')

    def setUp(self):
        if os.path.exists(self.tmp_dir):
            shutil.rmtree(self.tmp_dir)
        os.mkdir(self.tmp_dir)
        self.received_file_path = os.path.join(
            self.tmp_dir,
            'received_file.txt'
        )
        self.approved_file_path = os.path.join(
            self.tmp_dir,
            'approved_file.txt'
        )
        self.diff_tool = 'echo'
        os.environ[TextDiffReporter.DIFF_TOOL_ENVIRONMENT_VARIABLE_NAME] = self.diff_tool

    def tearDown(self):<commit_msg>Extract method to set env var.<commit_after>import os
import shutil
import unittest
from approvaltests.TextDiffReporter import TextDiffReporter


class TextDiffReportertests(unittest.TestCase):
    @staticmethod
    def set_environment_variable(name, value):
        os.environ[name] = value

    @property
    def tmp_dir(self):
        test_dir = os.path.dirname(os.path.realpath(__file__))
        return os.path.join(test_dir, 'tmp')

    def setUp(self):
        if os.path.exists(self.tmp_dir):
            shutil.rmtree(self.tmp_dir)
        os.mkdir(self.tmp_dir)
        self.received_file_path = os.path.join(
            self.tmp_dir,
            'received_file.txt'
        )
        self.approved_file_path = os.path.join(
            self.tmp_dir,
            'approved_file.txt'
        )
        self.diff_tool = 'echo'
        self.set_environment_variable(
            TextDiffReporter.DIFF_TOOL_ENVIRONMENT_VARIABLE_NAME,
            self.diff_tool
        )

    def tearDown(self):
{'fraction_non_alphanumeric': 0.09259259259259259, 'fraction_numerical': 0.0, 'mean_word_length': 2.433644859813084, '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': '6932583', 'n_tokens_mistral': 603, 'n_tokens_neox': 586, 'n_words': 91}