Skip to content

Commit 273069d

Browse files
committed
Fix traceback tests
1 parent 69e82f2 commit 273069d

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lazy from . import bar
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import traceback
2+
traceback.print_stack()
3+
while True: pass
4+
print("BAR_MODULE_LOADED")
5+
def f(): pass

Lib/test/test_traceback.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5596,11 +5596,11 @@ class TestLazyImportSuggestions(unittest.TestCase):
55965596

55975597
def test_attribute_error_does_not_reify_lazy_imports(self):
55985598
"""Printing an AttributeError should not trigger lazy import reification."""
5599-
# pkg.bar prints "BAR_MODULE_LOADED" when imported.
5599+
# lazypkg.bar prints "BAR_MODULE_LOADED" when imported.
56005600
# If lazy import is reified during suggestion computation, we'll see it.
56015601
code = textwrap.dedent("""
5602-
lazy import test.test_lazy_import.data.pkg.bar
5603-
test.test_lazy_import.data.pkg.nonexistent
5602+
lazy import test.test_lazy_import.data.lazypkg
5603+
test.test_lazy_import.data.lazypkg.nonexistent
56045604
""")
56055605
rc, stdout, stderr = assert_python_failure('-c', code)
56065606
self.assertNotIn(b"BAR_MODULE_LOADED", stdout)
@@ -5609,9 +5609,9 @@ def test_traceback_formatting_does_not_reify_lazy_imports(self):
56095609
"""Formatting a traceback should not trigger lazy import reification."""
56105610
code = textwrap.dedent("""
56115611
import traceback
5612-
lazy import test.test_lazy_import.data.pkg.bar
5612+
lazy import test.test_lazy_import.data.lazypkg
56135613
try:
5614-
test.test_lazy_import.data.pkg.nonexistent
5614+
test.test_lazy_import.data.lazypkg.nonexistent
56155615
except AttributeError:
56165616
traceback.format_exc()
56175617
print("OK")
@@ -5623,9 +5623,9 @@ def test_traceback_formatting_does_not_reify_lazy_imports(self):
56235623
def test_suggestion_still_works_for_non_lazy_attributes(self):
56245624
"""Suggestions should still work for non-lazy module attributes."""
56255625
code = textwrap.dedent("""
5626-
lazy import test.test_lazy_import.data.pkg.bar
5626+
lazy import test.test_lazy_import.data.lazypkg
56275627
# Typo for __name__
5628-
test.test_lazy_import.data.pkg.__nme__
5628+
test.test_lazy_import.data.lazypkg.__nme__
56295629
""")
56305630
rc, stdout, stderr = assert_python_failure('-c', code)
56315631
self.assertIn(b"__name__", stderr)

0 commit comments

Comments
 (0)