<commit_before>
import time
from django.test import TestCase
from .decorators import enable


class AfterResponseTest(TestCase):

    def test_execution(self):
        self.executed = 0

        @enable
        def func(val):
            if val:
                self.executed += 1

        self.assertEqual(self.executed, 0)
        self.client.get('/')
        self.assertEqual(self.executed, 0)

        func.after_response(True)

        self.assertEqual(self.executed, 0)
        self.client.get('/')
        self.assertEqual(self.executed, 1)

        func.after_response(True)
        func.after_response(True)

        self.assertEqual(self.executed, 1)
        self.client.get('/')
        self.assertEqual(self.executed, 3)

        func.after_response(False)
        func.after_response(True)

        self.assertEqual(self.executed, 3)
        self.client.get('/')
        self.assertEqual(self.executed, 4)

    def test_slow_execution(self):
        self.executed = 0

        @enable
        def slow_func():
            time.sleep(1)
            self.executed += 1

        slow_func.after_response()

        self.assertEqual(self.executed, 0)
        self.client.get('/')
        self.assertEqual(self.executed, 0)

        slow_func.after_response()

        before_time = time.time()
        self.client.get('/')
        after_time = time.time()
        self.assertTrue(after_time - before_time < 0.5)
<commit_msg>add a small sleep to make sync tests pass<commit_after>
import time
from django.test import TestCase
from .decorators import enable


class AfterResponseTest(TestCase):

    def test_execution(self):
        self.executed = 0

        @enable
        def func(val):
            if val:
                self.executed += 1

        self.assertEqual(self.executed, 0)
        self.client.get('/')
        time.sleep(0.1)
        self.assertEqual(self.executed, 0)

        func.after_response(True)

        self.assertEqual(self.executed, 0)
        self.client.get('/')
        time.sleep(0.1)
        self.assertEqual(self.executed, 1)

        func.after_response(True)
        func.after_response(True)

        self.assertEqual(self.executed, 1)
        self.client.get('/')
        time.sleep(0.1)
        self.assertEqual(self.executed, 3)

        func.after_response(False)
        func.after_response(True)

        self.assertEqual(self.executed, 3)
        self.client.get('/')
        time.sleep(0.1)
        self.assertEqual(self.executed, 4)

    def test_slow_execution(self):
        self.executed = 0

        @enable
        def slow_func():
            time.sleep(1)
            self.executed += 1

        slow_func.after_response()

        self.assertEqual(self.executed, 0)
        self.client.get('/')
        self.assertEqual(self.executed, 0)

        slow_func.after_response()

        before_time = time.time()
        self.client.get('/')
        after_time = time.time()
        self.assertTrue(after_time - before_time < 0.5)

{'fraction_non_alphanumeric': 0.11438127090301003, 'fraction_numerical': 0.014046822742474917, 'mean_word_length': 2.0, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7355155', 'n_tokens_mistral': 949, 'n_tokens_neox': 880, 'n_words': 160}