Python: Add tests for lazy from ... import * as well

This commit is contained in:
Taus
2026-04-13 11:49:06 +00:00
parent 86020d9eed
commit 2eeb31b472
3 changed files with 13 additions and 5 deletions

View File

@@ -3,5 +3,7 @@
| 4 | Import | lazy |
| 5 | Import | lazy |
| 6 | Import | lazy |
| 9 | Import | normal |
| 7 | from l import * | lazy |
| 10 | Import | normal |
| 11 | Import | normal |
| 12 | from w import * | normal |

View File

@@ -4,7 +4,9 @@ lazy from b import c
lazy from d import e as f
lazy import g.h as i
lazy from ..j import k
lazy from l import *
# Non-lazy imports
import x
from y import z
from w import *

View File

@@ -1,7 +1,11 @@
import python
string lazy(Import imp) { if imp.isLazy() then result = "lazy" else result = "normal" }
string lazy(Stmt s) {
if s.(Import).isLazy() or s.(ImportStar).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)
from Stmt s
where
s.getLocation().getFile().getShortName() = "test.py" and
(s instanceof Import or s instanceof ImportStar)
select s.getLocation().getStartLine(), s.toString(), lazy(s)