MCPcopy Create free account
hub / github.com/python/cpython / test_stacklevel_import

Method test_stacklevel_import

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

Source from the content-addressed store, hash-verified

619 "<sys>")
620
621 def test_stacklevel_import(self):
622 # Issue #24305: With stacklevel=2, module-level warnings should work.
623 import_helper.unload('test.test_warnings.data.import_warning')
624 with warnings_state(self.module):
625 with self.module.catch_warnings(record=True) as w:
626 self.module.simplefilter('always')
627 import test.test_warnings.data.import_warning # noqa: F401
628 self.assertEqual(len(w), 1)
629 self.assertEqual(w[0].filename, __file__)
630
631 def test_skip_file_prefixes(self):
632 with warnings_state(self.module):

Callers

nothing calls this directly

Calls 2

warnings_stateFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected