MCPcopy Index your code
hub / github.com/RustPython/RustPython / check

Method check

Lib/test/test_exceptions.py:215–232  ·  view source on GitHub ↗
(self, src, lineno, offset, end_lineno=None, end_offset=None, encoding='utf-8')

Source from the content-addressed store, hash-verified

213 ckmsg(s, "inconsistent use of tabs and spaces in indentation", TabError)
214
215 def check(self, src, lineno, offset, end_lineno=None, end_offset=None, encoding='utf-8'):
216 with self.subTest(source=src, lineno=lineno, offset=offset):
217 with self.assertRaises(SyntaxError) as cm:
218 compile(src, '<fragment>', 'exec')
219 self.assertEqual(cm.exception.lineno, lineno)
220 self.assertEqual(cm.exception.offset, offset)
221 if end_lineno is not None:
222 self.assertEqual(cm.exception.end_lineno, end_lineno)
223 if end_offset is not None:
224 self.assertEqual(cm.exception.end_offset, end_offset)
225
226 if cm.exception.text is not None:
227 if not isinstance(src, str):
228 src = src.decode(encoding, 'replace')
229 line = src.split('\n')[lineno-1]
230 if lineno == 1:
231 line = line.removeprefix('\ufeff')
232 self.assertIn(line, cm.exception.text)
233
234 @unittest.expectedFailure # TODO: RUSTPYTHON
235 def test_error_offset_continuation_characters(self):

Callers

nothing calls this directly

Calls 9

isinstanceFunction · 0.85
subTestMethod · 0.80
assertInMethod · 0.80
compileFunction · 0.50
assertRaisesMethod · 0.45
assertEqualMethod · 0.45
decodeMethod · 0.45
splitMethod · 0.45
removeprefixMethod · 0.45

Tested by

no test coverage detected