<commit_before># coding: utf-8
import os
import sys
import time
import atexit
import shutil
import tempfile
import unittest
from warnings import catch_warnings
from contextlib import closing

from flask import Flask
from flask.ext.makestatic import MakeStatic, is_newer, RuleMissing


TEST_APPS = os.path.join(os.path.dirname(__file__), 'test_apps')
sys.path.insert(0, TEST_APPS)


def get_temporary_filename():
    filename = tempfile.mkstemp()[1]
    @atexit.register
    def remove_file():
        try:
            os.remove(filename)
        except EnvironmentError:
            pass
    return filename


class MakeStaticTestCase(unittest.TestCase):
    def tearDown(self):
        for test_app_dir in os.listdir(TEST_APPS):
            static_dir = os.path.join(TEST_APPS, test_app_dir, 'static')
            if os.path.isdir(static_dir):
                shutil.rmtree(static_dir)
                os.mkdir(static_dir)

    def test_send_static_file_patch(self):
        app = Flask('working')
        make_static = MakeStatic(app)
        assert make_static # pyflakes...

        with app.test_request_context():
            with closing(app.send_static_file('foo')) as response:
                self.assertEqual(response.status_code, 200)
<commit_msg>Don't delete .gitignore in tearDown<commit_after># coding: utf-8
import os
import sys
import time
import atexit
import tempfile
import unittest
from warnings import catch_warnings
from contextlib import closing

from flask import Flask
from flask.ext.makestatic import MakeStatic, is_newer, RuleMissing


TEST_APPS = os.path.join(os.path.dirname(__file__), 'test_apps')
sys.path.insert(0, TEST_APPS)


def get_temporary_filename():
    filename = tempfile.mkstemp()[1]
    @atexit.register
    def remove_file():
        try:
            os.remove(filename)
        except EnvironmentError:
            pass
    return filename


class MakeStaticTestCase(unittest.TestCase):
    def tearDown(self):
        for test_app_dir in os.listdir(TEST_APPS):
            static_dir = os.path.join(TEST_APPS, test_app_dir, 'static')
            if os.path.isdir(static_dir):
                for root, dirs, files in os.walk(static_dir):
                    for file in files:
                        if file == '.gitignore':
                            continue
                        os.remove(os.path.join(root, file))
                    for dir in dirs:
                        os.rmdir(os.path.join(root, dir))

    def test_send_static_file_patch(self):
        app = Flask('working')
        make_static = MakeStatic(app)
        assert make_static # pyflakes...

        with app.test_request_context():
            with closing(app.send_static_file('foo')) as response:
                self.assertEqual(response.status_code, 200)

{'fraction_non_alphanumeric': 0.087486554320545, 'fraction_numerical': 0.004302617425600574, 'mean_word_length': 2.536121673003802, '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': '3555958', 'n_tokens_mistral': 846, 'n_tokens_neox': 809, 'n_words': 196}