mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Python: Add test for implicit __init__.py files
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
debug_missingAnnotationForCallable
|
||||
debug_nonUniqueAnnotationForCallable
|
||||
debug_missingAnnotationForCall
|
||||
expectedCallEdgeNotFound
|
||||
| example.py:12:1:12:7 | afunc() | foo/bar/a.py:2:1:2:12 | Function afunc |
|
||||
unexpectedCallEdgeFound
|
||||
@@ -0,0 +1 @@
|
||||
../CallGraph/PointsTo.ql
|
||||
@@ -0,0 +1,5 @@
|
||||
debug_missingAnnotationForCallable
|
||||
debug_nonUniqueAnnotationForCallable
|
||||
debug_missingAnnotationForCall
|
||||
pointsTo_found_typeTracker_notFound
|
||||
pointsTo_notFound_typeTracker_found
|
||||
@@ -0,0 +1 @@
|
||||
../CallGraph/Relative.ql
|
||||
@@ -0,0 +1,6 @@
|
||||
debug_missingAnnotationForCallable
|
||||
debug_nonUniqueAnnotationForCallable
|
||||
debug_missingAnnotationForCall
|
||||
expectedCallEdgeNotFound
|
||||
| example.py:12:1:12:7 | afunc() | foo/bar/a.py:2:1:2:12 | Function afunc |
|
||||
unexpectedCallEdgeFound
|
||||
@@ -0,0 +1 @@
|
||||
../CallGraph/TypeTracker.ql
|
||||
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
Test that we can resolve callables correctly without using explicit __init__.py files
|
||||
|
||||
This is not included in the standard `CallGraph/code` folder, since we're testing our
|
||||
understanding import work properly, so it's better to have a clean test setup that is
|
||||
obviously correct (the other one isn't in regards to imports).
|
||||
|
||||
Technically this is part of PEP 420 -- Implicit Namespace Packages, but does use the
|
||||
*real* namespace package feature of allowing source code for a single package to reside
|
||||
in multiple places.
|
||||
|
||||
Since PEP 420 was accepted in Python 3, this test is Python 3 only.
|
||||
"""
|
||||
|
||||
from foo.bar.a import afunc
|
||||
|
||||
# calls:afunc
|
||||
afunc()
|
||||
@@ -0,0 +1,4 @@
|
||||
# name:afunc
|
||||
def afunc():
|
||||
print("afunc called")
|
||||
return 1
|
||||
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --max-import-depth=1 --lang=3
|
||||
Reference in New Issue
Block a user