<commit_before>#!/usr/bin/env python

from unittest import TestCase
from utile import enforce, EnforcementError, enforce_clean_exit


@enforce_clean_exit
def clean_exit_test(x):
    enforce(x < 0, 'x must be negative')


class EnforceTestCase(TestCase):
    def setUp(self):
        self.x = 10

    def test_enforce_true(self):
        enforce(self.x > 0, 'x must be positive')

    def test_enforce_false(self):
        with self.assertRaisesRegexp(EnforcementError, 'x must be negative'):
            enforce(self.x < 0, 'x must be negative')

    def test_enforce_custom_exception(self):
        with self.assertRaisesRegexp(ValueError, 'x must be negative'):
            enforce(self.x < 0, 'x must be negative', ValueError)

    def test_enforce_clean_exit(self):
        with self.assertRaisesRegexp(SystemExit, 'x must be negative'):
            clean_exit_test(self.x)<commit_msg>renamed test function so that nose doesn't mistake it for a test case<commit_after>#!/usr/bin/env python

from unittest import TestCase
from utile import enforce, EnforcementError, enforce_clean_exit


@enforce_clean_exit
def demo_clean_exit(x):
    enforce(x < 0, 'x must be negative')


class EnforceTestCase(TestCase):
    def setUp(self):
        self.x = 10

    def test_enforce_true(self):
        enforce(self.x > 0, 'x must be positive')

    def test_enforce_false(self):
        with self.assertRaisesRegexp(EnforcementError, 'x must be negative'):
            enforce(self.x < 0, 'x must be negative')

    def test_enforce_custom_exception(self):
        with self.assertRaisesRegexp(ValueError, 'x must be negative'):
            enforce(self.x < 0, 'x must be negative', ValueError)

    def test_enforce_clean_exit(self):
        with self.assertRaisesRegexp(SystemExit, 'x must be negative'):
            demo_clean_exit(self.x)
{'fraction_non_alphanumeric': 0.09432933478735006, 'fraction_numerical': 0.006543075245365322, 'mean_word_length': 3.5085995085995085, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '6574298', 'n_tokens_mistral': 590, 'n_tokens_neox': 565, 'n_words': 157}