Skip to content

Commit 362cf10

Browse files
committed
python: add tests for module import
- `--max-import-depth=3` to give points-to a chance - `not_root` dir to force namespace package logic - add usage in `example.py` to get files extracted
1 parent dbecb1b commit 362cf10

File tree

8 files changed

+29
-5
lines changed

8 files changed

+29
-5
lines changed

python/ql/test/experimental/library-tests/CallGraph-implicit-init/example.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616

1717
from foo.bar.a import afunc
1818
from foo_explicit.bar.a import explicit_afunc
19+
from not_root.baz.foo import foo_func
20+
from not_root.baz.bar.a import afunc as afunc2
1921

2022
afunc() # $ pt,tt="foo/bar/a.py:afunc"
2123

2224
explicit_afunc() # $ pt,tt="foo_explicit/bar/a.py:explicit_afunc"
25+
26+
foo_func() # $ pt,tt="not_root/baz/foo.py:foo_func"
27+
28+
afunc2() # $ pt,tt="not_root/baz/bar/a.py:afunc"
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
def afunc():
2-
print("afunc called")
3-
return 1
2+
print("afunc called")
3+
return 1
4+
5+
from foo.foo import foo_func
6+
foo_func() # $ pt,tt="foo/foo.py:foo_func"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def foo_func():
2+
print("foo_func called")
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
def explicit_afunc():
2-
print("explicit_afunc called")
3-
return 1
2+
print("explicit_afunc called")
3+
return 1
4+
5+
from foo_explicit.foo_explicit import foo_explicit_func
6+
foo_explicit_func() # $ pt,tt="foo_explicit/foo_explicit.py:foo_explicit_func"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def foo_explicit_func():
2+
print("foo_explicit_func called")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def afunc():
2+
print("afunc called")
3+
return 1
4+
5+
from baz.foo import foo_func
6+
foo_func() # $ MISSING: pt,tt="baz/foo.py:foo_func"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def foo_func():
2+
print("foo_func called")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
semmle-extractor-options: --max-import-depth=1 --lang=3
1+
semmle-extractor-options: --max-import-depth=3 --lang=3

0 commit comments

Comments
 (0)