MCPcopy Index your code
hub / github.com/python/cpython / test_syntax_error

Method test_syntax_error

Lib/test/test_code_module.py:94–112  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

92 raise AssertionError("no console stdout")
93
94 def test_syntax_error(self):
95 self.infunc.side_effect = ["def f():",
96 " x = ?",
97 "",
98 EOFError('Finished')]
99 self.console.interact()
100 output = ''.join(''.join(call[1]) for call in self.stderr.method_calls)
101 output = output[output.index('(InteractiveConsole)'):]
102 output = output[:output.index('\nnow exiting')]
103 self.assertEqual(output.splitlines()[1:], [
104 ' File "<console>", line 2',
105 ' x = ?',
106 ' ^',
107 'SyntaxError: invalid syntax'])
108 self.assertIs(self.sysmod.last_type, SyntaxError)
109 self.assertIs(type(self.sysmod.last_value), SyntaxError)
110 self.assertIsNone(self.sysmod.last_traceback)
111 self.assertIsNone(self.sysmod.last_value.__traceback__)
112 self.assertIs(self.sysmod.last_exc, self.sysmod.last_value)
113
114 def test_indentation_error(self):
115 self.infunc.side_effect = [" 1", EOFError('Finished')]

Callers

nothing calls this directly

Calls 7

assertIsNoneMethod · 0.80
interactMethod · 0.45
joinMethod · 0.45
indexMethod · 0.45
assertEqualMethod · 0.45
splitlinesMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected