Python: Add test for implicit __init__.py files

This commit is contained in:
Rasmus Wriedt Larsen
2020-09-25 11:44:54 +02:00
parent 120a569c6f
commit 3d5511221e
9 changed files with 43 additions and 0 deletions

View File

@@ -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

View File

@@ -0,0 +1 @@
../CallGraph/PointsTo.ql

View File

@@ -0,0 +1,5 @@
debug_missingAnnotationForCallable
debug_nonUniqueAnnotationForCallable
debug_missingAnnotationForCall
pointsTo_found_typeTracker_notFound
pointsTo_notFound_typeTracker_found

View File

@@ -0,0 +1 @@
../CallGraph/Relative.ql

View File

@@ -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

View File

@@ -0,0 +1 @@
../CallGraph/TypeTracker.ql

View File

@@ -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()

View File

@@ -0,0 +1,4 @@
# name:afunc
def afunc():
print("afunc called")
return 1

View File

@@ -0,0 +1 @@
semmle-extractor-options: --max-import-depth=1 --lang=3