def setUp(self):  # called for each test - test fixture
        all_ops = [
            operator('+', 0, (lambda y, x: x + y)),
            operator('-', 0, (lambda y, x: x - y)),
            operator('*', 1, (lambda y, x: x * y)),
            operator('/', 1, (lambda y, x: x / y)),
            operator('^', 2, (lambda y, x: pow(x, y)), pos='right'),
        ]

        all_funcs = [
            function('pluss', (lambda y, x, z: x + y + z)),
            function('pi', (lambda: Decimal(3.14))),
        ]

        self.subj = reverse_polish_notation(all_ops, all_funcs)

        self.cases = [
            ['0-((-8/(-2))+123)-111', '0 0 8 - 0 2 - / 123 + - 111 -', -238],
            ['1-(999-(-888-(-777-(-666-(-555-(-123456789+(0-(0-'
             + '(-8/-2)+123)-111)-0)-0)+999)/1)*1)+333)',
             '1 999 0 888 - 0 777 - 0 666 - 0 555 - 0 123456789 - 0 0 0 8'
             + ' - 0 2 - / - 123 + - 111 - + 0 - - 0 - - 999 + 1 / - 1 *'
             + ' - - 333 + -', -123457573],
            ['-(-(-(-(-(-(-(-(-(-8/-2)))))))))',
             '0 0 0 0 0 0 0 0 0 0 8 - 0 2 - / - - - - - - - - -', -4],
            ['-1', '0 1 -', -1]
        ]
    def setUp(self):  # called for each test - test fixture
        self.add = operator('+', 0, (lambda y, x: x + y))
        self.sub = operator('-', 0, (lambda y, x: x - y))
        self.mul = operator('*', 1, (lambda y, x: x * y))
        self.div = operator('/', 1, (lambda y, x: x / y))
        self.powr = operator('^', 2, (lambda y, x: pow(x, y)), pos='right')

        self.pluss = function('pluss', (lambda y, x, z: x + y + z))
        self.pi = function('pi', (lambda: 3.14))
                stack.append(res)
            elif i in self.fun.keys():  # if token is a function
                res = self.fun[i](stack)
                stack.append(res)
            else:
                stack.append(i)

        return stack[0]


if __name__ == '__main__':  # pragma: no cover
    all_ops = [
        operator('+', 0, (lambda y, x: x + y)),
        operator('-', 0, (lambda y, x: x - y)),
        operator('*', 1, (lambda y, x: x * y)),
        operator('/', 1, (lambda y, x: x / y)),
        operator('^', 2, (lambda y, x: pow(x, y)), pos='right'),
    ]

    all_funcs = [
        function('pluss', (lambda y, x, z: x + y + z)),
        function('pi', (lambda: Decimal(3.14))),
    ]

    pol_nat = reverse_polish_notation(all_ops, all_funcs)

    e = 'pi() * pluss(9, 1, 1) ^ 2 * 9 + 4 / (1 * 2)'
    r = pol_nat.get_rev_pol(pol_nat.parse_ex(e))
    r = pol_nat.calc_rev_pol(r)
    print(r)