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

Method test_stacklevel

Lib/test/test_warnings/__init__.py:542–566  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

540 "stacklevel.py")
541
542 def test_stacklevel(self):
543 # Test stacklevel argument
544 # make sure all messages are different, so the warning won't be skipped
545 with warnings_state(self.module):
546 with self.module.catch_warnings(record=True) as w:
547 warning_tests.inner("spam3", stacklevel=1)
548 self.assertEqual(os.path.basename(w[-1].filename),
549 "stacklevel.py")
550 warning_tests.outer("spam4", stacklevel=1)
551 self.assertEqual(os.path.basename(w[-1].filename),
552 "stacklevel.py")
553
554 warning_tests.inner("spam5", stacklevel=2)
555 self.assertEqual(os.path.basename(w[-1].filename),
556 "__init__.py")
557 warning_tests.outer("spam6", stacklevel=2)
558 self.assertEqual(os.path.basename(w[-1].filename),
559 "stacklevel.py")
560 warning_tests.outer("spam6.5", stacklevel=3)
561 self.assertEqual(os.path.basename(w[-1].filename),
562 "__init__.py")
563
564 warning_tests.inner("spam7", stacklevel=9999)
565 self.assertEqual(os.path.basename(w[-1].filename),
566 "<sys>")
567
568 @unittest.expectedFailure # TODO: RUSTPYTHON; + /Users/al03219714/Projects/RustPython1/crates/pylib/Lib/test/test_warnings/__init__.py
569 def test_stacklevel_import(self):

Callers

nothing calls this directly

Calls 5

warnings_stateFunction · 0.85
basenameMethod · 0.80
innerMethod · 0.45
assertEqualMethod · 0.45
outerMethod · 0.45

Tested by

no test coverage detected