diff --git a/python/ql/test/3/extractor-tests/lazy-imports/test.expected b/python/ql/test/3/extractor-tests/lazy-imports/test.expected new file mode 100644 index 00000000000..9eb4f975dc4 --- /dev/null +++ b/python/ql/test/3/extractor-tests/lazy-imports/test.expected @@ -0,0 +1,7 @@ +| 2 | Import | lazy | +| 3 | Import | lazy | +| 4 | Import | lazy | +| 5 | Import | lazy | +| 6 | Import | lazy | +| 9 | Import | normal | +| 10 | Import | normal | diff --git a/python/ql/test/3/extractor-tests/lazy-imports/test.py b/python/ql/test/3/extractor-tests/lazy-imports/test.py new file mode 100644 index 00000000000..775cac00bbf --- /dev/null +++ b/python/ql/test/3/extractor-tests/lazy-imports/test.py @@ -0,0 +1,10 @@ +# Lazy imports (PEP 810) +lazy import a +lazy from b import c +lazy from d import e as f +lazy import g.h as i +lazy from ..j import k + +# Non-lazy imports +import x +from y import z diff --git a/python/ql/test/3/extractor-tests/lazy-imports/test.ql b/python/ql/test/3/extractor-tests/lazy-imports/test.ql new file mode 100644 index 00000000000..312019c7cd1 --- /dev/null +++ b/python/ql/test/3/extractor-tests/lazy-imports/test.ql @@ -0,0 +1,7 @@ +import python + +string lazy(Import imp) { if imp.isLazy() then result = "lazy" else result = "normal" } + +from Import imp +where imp.getLocation().getFile().getShortName() = "test.py" +select imp.getLocation().getStartLine(), imp.toString(), lazy(imp)