'See that `StudentInputError`s are raised when things go wrong.'

def test_err_handling(self):

    problem = self.build_problem(answer=4)
    errors = [(calc.UndefinedVariable('x'), 'You    may    not    use    variables    \\(x\\)    in    numerical    problems'), (ValueError('factorial()    mess-up'), 'Factorial    function    evaluated    outside    its    domain'), (ValueError(), "Could    not    interpret    '.*'    as    a    number"), (pyparsing.ParseException('oopsie'), 'Invalid    math    syntax'), (ZeroDivisionError(), "Could    not    interpret    '.*'    as    a    number")]
    with mock.patch('capa.responsetypes.evaluator') as mock_eval:
        for (err, msg_regex) in errors:
            def evaluator_side_effect(_, __, math_string):
                'Raise    an    error    only    for    the    student    input.'
                if (math_string != '4'):
                    raise err
            mock_eval.side_effect = evaluator_side_effect
            with self.assertRaisesRegexp(StudentInputError, msg_regex):
                problem.grade_answers({'1_2_1': 'foobar'})
