<commit_before>from bamboo.core.parser import ParseError, Parser
from bamboo.tests.test_base import TestBase


class TestParser(TestBase):

    def setUp(self):
        self.parser = Parser()
        self.row = {'VAR': 1}
        TestBase.setUp(self)

    def _check_func(self, parse_result):
        functions = parse_result
        for func in functions:
            self.assertEqual(func.func.func_name, 'eval')
        return functions[0]

    def test_parse_formula(self):
        func = self._check_func(
            self.parser.parse_formula('VAR'))
        self.assertEqual(func(self.row, self.parser.context), 1)

    def test_bnf(self):
        result = self.parser._build_bnf()
        self.assertNotEqual(self.parser.bnf, None)

    def test_parse_formula_with_var(self):
        func = self._check_func(
            self.parser.parse_formula('VAR + 1'))
        self.assertEqual(func(self.row, self.parser.context), 2)

    def test_parse_formula_bad_formula(self):
        bad_formulas = [
            '=BAD +++ FOR',
            '2 +>+ 1',
            '1 ** 2',
        ]

        for bad_formula in bad_formulas:
            self.assertRaises(ParseError, self.parser.parse_formula,
                              bad_formula)<commit_msg>fix private test call<commit_after>from bamboo.core.parser import ParseError, Parser
from bamboo.tests.test_base import TestBase


class TestParser(TestBase):

    def setUp(self):
        self.parser = Parser()
        self.row = {'VAR': 1}
        TestBase.setUp(self)

    def _check_func(self, parse_result):
        functions = parse_result
        for func in functions:
            self.assertEqual(func.func.func_name, 'eval')
        return functions[0]

    def test_parse_formula(self):
        func = self._check_func(
            self.parser.parse_formula('VAR'))
        self.assertEqual(func(self.row, self.parser.context), 1)

    def test_bnf(self):
        result = self.parser._Parser__build_bnf()
        self.assertNotEqual(self.parser.bnf, None)

    def test_parse_formula_with_var(self):
        func = self._check_func(
            self.parser.parse_formula('VAR + 1'))
        self.assertEqual(func(self.row, self.parser.context), 2)

    def test_parse_formula_bad_formula(self):
        bad_formulas = [
            '=BAD +++ FOR',
            '2 +>+ 1',
            '1 ** 2',
        ]

        for bad_formula in bad_formulas:
            self.assertRaises(ParseError, self.parser.parse_formula,
                              bad_formula)
{'fraction_non_alphanumeric': 0.10873015873015873, 'fraction_numerical': 0.007142857142857143, 'mean_word_length': 2.2825520833333335, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4639274', 'n_tokens_mistral': 800, 'n_tokens_neox': 746, 'n_words': 144}