Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Lib/test/test_import/test_lazy_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,30 +232,30 @@ def tearDown(self):
def test_lazy_try_except(self):
"""lazy import inside try/except should raise SyntaxError."""
with self.assertRaises(SyntaxError):
import test.test_import.data.lazy_imports.lazy_try_except
import test.test_import.data.lazy_imports.badsyntax.lazy_try_except

def test_lazy_try_except_from(self):
"""lazy from import inside try/except should raise SyntaxError."""
with self.assertRaises(SyntaxError):
import test.test_import.data.lazy_imports.lazy_try_except_from
import test.test_import.data.lazy_imports.badsyntax.lazy_try_except_from

def test_lazy_try_except_from_star(self):
"""lazy from import * should raise SyntaxError."""
with self.assertRaises(SyntaxError):
import test.test_import.data.lazy_imports.lazy_try_except_from_star
import test.test_import.data.lazy_imports.badsyntax.lazy_try_except_from_star

def test_lazy_future_import(self):
"""lazy from __future__ import should raise SyntaxError."""
with self.assertRaises(SyntaxError) as cm:
import test.test_import.data.lazy_imports.lazy_future_import
import test.test_import.data.lazy_imports.badsyntax.lazy_future_import
# Check we highlight 'lazy' (column offset 0, end offset 4)
self.assertEqual(cm.exception.offset, 1)
self.assertEqual(cm.exception.end_offset, 5)

def test_lazy_import_func(self):
"""lazy import inside function should raise SyntaxError."""
with self.assertRaises(SyntaxError):
import test.test_import.data.lazy_imports.lazy_import_func
import test.test_import.data.lazy_imports.badsyntax.lazy_import_func

def test_lazy_import_exec_in_function(self):
"""lazy import via exec() inside a function should raise SyntaxError."""
Expand Down Expand Up @@ -1223,7 +1223,7 @@ def test_lazy_import_inside_class_raises_syntax_error(self):
# PEP 810: "The soft keyword is only allowed at the global (module) level,
# not inside functions, class bodies, try blocks, or import *"
with self.assertRaises(SyntaxError):
import test.test_import.data.lazy_imports.lazy_class_body
import test.test_import.data.lazy_imports.badsyntax.lazy_class_body


class MixedLazyEagerImportTests(unittest.TestCase):
Expand Down
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -2684,6 +2684,7 @@ TESTSUBDIRS= idlelib/idle_test \
test/test_import/data/unwritable \
test/test_import/data/lazy_imports \
test/test_import/data/lazy_imports/pkg \
test/test_import/data/lazy_imports/badsyntax \
test/test_importlib \
test/test_importlib/builtin \
test/test_importlib/extension \
Expand Down
Loading