mirror of
https://github.com/github/codeql.git
synced 2025-12-22 03:36:30 +01:00
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
This commit is contained in:
committed by
yoff
parent
dbecb1bd0f
commit
362cf107a4
@@ -16,7 +16,13 @@ Since PEP 420 was accepted in Python 3, this test is Python 3 only.
|
|||||||
|
|
||||||
from foo.bar.a import afunc
|
from foo.bar.a import afunc
|
||||||
from foo_explicit.bar.a import explicit_afunc
|
from foo_explicit.bar.a import explicit_afunc
|
||||||
|
from not_root.baz.foo import foo_func
|
||||||
|
from not_root.baz.bar.a import afunc as afunc2
|
||||||
|
|
||||||
afunc() # $ pt,tt="foo/bar/a.py:afunc"
|
afunc() # $ pt,tt="foo/bar/a.py:afunc"
|
||||||
|
|
||||||
explicit_afunc() # $ pt,tt="foo_explicit/bar/a.py:explicit_afunc"
|
explicit_afunc() # $ pt,tt="foo_explicit/bar/a.py:explicit_afunc"
|
||||||
|
|
||||||
|
foo_func() # $ pt,tt="not_root/baz/foo.py:foo_func"
|
||||||
|
|
||||||
|
afunc2() # $ pt,tt="not_root/baz/bar/a.py:afunc"
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
def afunc():
|
def afunc():
|
||||||
print("afunc called")
|
print("afunc called")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
from foo.foo import foo_func
|
||||||
|
foo_func() # $ pt,tt="foo/foo.py:foo_func"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
def foo_func():
|
||||||
|
print("foo_func called")
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
def explicit_afunc():
|
def explicit_afunc():
|
||||||
print("explicit_afunc called")
|
print("explicit_afunc called")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
from foo_explicit.foo_explicit import foo_explicit_func
|
||||||
|
foo_explicit_func() # $ pt,tt="foo_explicit/foo_explicit.py:foo_explicit_func"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
def foo_explicit_func():
|
||||||
|
print("foo_explicit_func called")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
def afunc():
|
||||||
|
print("afunc called")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
from baz.foo import foo_func
|
||||||
|
foo_func() # $ MISSING: pt,tt="baz/foo.py:foo_func"
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
def foo_func():
|
||||||
|
print("foo_func called")
|
||||||
@@ -1 +1 @@
|
|||||||
semmle-extractor-options: --max-import-depth=1 --lang=3
|
semmle-extractor-options: --max-import-depth=3 --lang=3
|
||||||
|
|||||||
Reference in New Issue
Block a user