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

Method _test_exception

Lib/test/test_pyexpat.py:478–507  ·  view source on GitHub ↗
(self, have_source)

Source from the content-addressed store, hash-verified

476 self._test_exception(have_source)
477
478 def _test_exception(self, have_source):
479 # Use path relative to the current directory which should be the Python
480 # source code directory (if it is available).
481 PYEXPAT_C = os.path.join('Modules', 'pyexpat.c')
482
483 parser = expat.ParserCreate()
484 parser.StartElementHandler = self.StartElementHandler
485 try:
486 parser.Parse(b"<a><b><c/></b></a>", True)
487
488 self.fail("the parser did not raise RuntimeError")
489 except RuntimeError as exc:
490 self.assertEqual(exc.args[0], 'StartElementHandler: <a>', exc)
491 entries = traceback.extract_tb(exc.__traceback__)
492
493 self.assertEqual(len(entries), 3, entries)
494 self.check_traceback_entry(entries[0],
495 "test_pyexpat.py", "_test_exception")
496 self.check_traceback_entry(entries[1],
497 os.path.basename(PYEXPAT_C),
498 "StartElement")
499 self.check_traceback_entry(entries[2],
500 "test_pyexpat.py", "StartElementHandler")
501
502 # Check that the traceback contains the relevant line in
503 # Modules/pyexpat.c. Skip the test if Modules/pyexpat.c is not
504 # available.
505 if have_source and os.path.exists(PYEXPAT_C):
506 self.assertIn('call_with_frame("StartElement"',
507 entries[1].line)
508
509
510# Test Current* members:

Callers 1

test_exceptionMethod · 0.95

Calls 8

check_traceback_entryMethod · 0.95
lenFunction · 0.85
basenameMethod · 0.80
assertInMethod · 0.80
joinMethod · 0.45
failMethod · 0.45
assertEqualMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected