def test_bad_recursion(self): contextualize_report(""" def to_pig_latin(str): first = str[0] str = str[1:] str = str + first + "ay" to_pig_latin("hello")""") commands.run() commands.call('to_pig_latin', 'test', threaded=True) self.assertNotIsInstance(commands.get_exception(), RecursionError)
def test_block_exit(self): contextualize_report("exit()") commands.run() self.assertIsNotNone(commands.get_exception())
def test_range_requires_integer(self): contextualize_report("x = 5") commands.run() x = commands.evaluate("x") range(x) self.assertIsNone(commands.get_exception())
def test_int_requires_integer(self): contextualize_report("x = '5'") commands.run() x = int(commands.evaluate("x")) self.assertIsNone(commands.get_exception())
def test_commands_exceptions(self): student_code = '1 + "Banana"' set_source(student_code) commands.run() self.assertIsNotNone(commands.get_exception())