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

Method test_skip_file_prefixes

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

Source from the content-addressed store, hash-verified

577 self.assertEqual(w[0].filename, __file__)
578
579 def test_skip_file_prefixes(self):
580 with warnings_state(self.module):
581 with self.module.catch_warnings(record=True) as w:
582 self.module.simplefilter('always')
583
584 # Warning never attributed to the data/ package.
585 package_helper.inner_api(
586 "inner_api", stacklevel=2,
587 warnings_module=warning_tests.warnings)
588 self.assertEqual(w[-1].filename, __file__)
589 warning_tests.package("package api", stacklevel=2)
590 self.assertEqual(w[-1].filename, __file__)
591 self.assertEqual(w[-2].filename, w[-1].filename)
592 # Low stacklevels are overridden to 2 behavior.
593 warning_tests.package("package api 1", stacklevel=1)
594 self.assertEqual(w[-1].filename, __file__)
595 warning_tests.package("package api 0", stacklevel=0)
596 self.assertEqual(w[-1].filename, __file__)
597 warning_tests.package("package api -99", stacklevel=-99)
598 self.assertEqual(w[-1].filename, __file__)
599
600 # The stacklevel still goes up out of the package.
601 warning_tests.package("prefix02", stacklevel=3)
602 self.assertIn("unittest", w[-1].filename)
603
604 def test_skip_file_prefixes_file_path(self):
605 # see: gh-126209

Callers

nothing calls this directly

Calls 4

warnings_stateFunction · 0.85
assertInMethod · 0.80
assertEqualMethod · 0.45
packageMethod · 0.45

Tested by

no test coverage detected