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

Method check

Lib/test/test_exceptions.py:212–229  ·  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

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

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected