<commit_before>import unittest2

from penchy.tests.util import MockPipelineElement


class PipelineElementHookTest(unittest2.TestCase):
    def setUp(self):
        self.e = MockPipelineElement()
        self.list_ = [23, 42, 5]

    def test_pre_hooks(self):
        self.e.prehooks = [
            lambda: self.list_.__setitem__(0, 1),
            lambda: self.list_.__setitem__(1, 1),
            lambda: self.list_.__setitem__(2, 1)]

        self.e.run()

        self.assertListEqual(self.list_, [1, 1, 1])

    def test_post_hooks(self):
        self.e.posthooks = [
            lambda: self.list_.__setitem__(0, 1),
            lambda: self.list_.__setitem__(1, 1),
            lambda: self.list_.__setitem__(2, 1)]

        self.e.run()

        self.assertListEqual(self.list_, [1, 1, 1])<commit_msg>tests: Test not runnable elements.<commit_after>import unittest2

from penchy.jobs.elements import Workload, Tool
from penchy.tests.util import MockPipelineElement


class PipelineElementHookTest(unittest2.TestCase):
    def setUp(self):
        self.e = MockPipelineElement()
        self.list_ = [23, 42, 5]

    def test_pre_hooks(self):
        self.e.prehooks = [
            lambda: self.list_.__setitem__(0, 1),
            lambda: self.list_.__setitem__(1, 1),
            lambda: self.list_.__setitem__(2, 1)]

        self.e.run()

        self.assertListEqual(self.list_, [1, 1, 1])

    def test_post_hooks(self):
        self.e.posthooks = [
            lambda: self.list_.__setitem__(0, 1),
            lambda: self.list_.__setitem__(1, 1),
            lambda: self.list_.__setitem__(2, 1)]

        self.e.run()

        self.assertListEqual(self.list_, [1, 1, 1])


class NotRunnableTest(unittest2.TestCase):
    def test_throw_exception(self):
        w = Workload()
        t = Tool()
        with self.assertRaises(ValueError):
            w.run()
        with self.assertRaises(ValueError):
            t.run()
{'fraction_non_alphanumeric': 0.12371134020618557, 'fraction_numerical': 0.026288659793814433, 'mean_word_length': 2.358131487889273, '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': '1051768', 'n_tokens_mistral': 671, 'n_tokens_neox': 630, 'n_words': 122}