<commit_before>from unittest2 import TestCase, main
from py_sak.functions import try_catch


class FunctionsTest(TestCase):
    def test_try_catch_no_args(self):
        self.assertEquals(try_catch(lambda: 1337), 1337)

    def test_try_catch_one_arg(self):
        self.assertEquals(try_catch(lambda x: x+1337, 1), 1338)

    def test_try_catch_two_args(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, 1, 1), 1339)

    def test_try_catch_args_list_one_arg(self):
        self.assertEquals(try_catch(lambda x: x+1337, *[1]), 1338)

    def test_try_catch_args_list_two_args(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, *[1, 1]), 1339)

    def test_try_catch_args_tuple_two_args(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, *(1, 1)), 1339)

    def test_try_catch_args_dict_one_arg(self):
        self.assertEquals(try_catch(lambda x: x+1337, **{'x':1}), 1338)

    def test_try_catch_args_dict_two_args(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, **{'x':1, 'y':1}), 1339)

    def test_try_catch_exception(self):
        error = RuntimeError(42)
        def throws():
            raise error
        self.assertEquals(try_catch(throws), error)
<commit_msg>Added tests for named arguments in functions_test.py.<commit_after>from unittest2 import TestCase, main
from py_sak.functions import try_catch


class FunctionsTest(TestCase):
    def test_try_catch_no_args(self):
        self.assertEquals(try_catch(lambda: 1337), 1337)

    def test_try_catch_one_arg(self):
        self.assertEquals(try_catch(lambda x: x+1337, 1), 1338)

    def test_try_catch_two_args(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, 1, 1), 1339)

    def test_try_catch_named_args_one_arg(self):
        self.assertEquals(try_catch(lambda x: x+1337, x=1), 1338)

    def test_try_catch_named_args_two_args_one_named(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, 1, y=1), 1339)

    def test_try_catch_args_list_one_arg(self):
        self.assertEquals(try_catch(lambda x: x+1337, *[1]), 1338)

    def test_try_catch_args_list_two_args(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, *[1, 1]), 1339)

    def test_try_catch_args_tuple_two_args(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, *(1, 1)), 1339)

    def test_try_catch_args_dict_one_arg(self):
        self.assertEquals(try_catch(lambda x: x+1337, **{'x':1}), 1338)

    def test_try_catch_args_dict_two_args(self):
        self.assertEquals(try_catch(lambda x,y: x+y+1337, **{'x':1, 'y':1}), 1339)

    def test_try_catch_exception(self):
        error = RuntimeError(42)
        def throws():
            raise error
        self.assertEquals(try_catch(throws), error)

{'fraction_non_alphanumeric': 0.12346125995655322, 'fraction_numerical': 0.06335988414192614, 'mean_word_length': 4.272900763358779, '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': '887119', 'n_tokens_mistral': 1120, 'n_tokens_neox': 988, 'n_words': 179}