Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d55112

Browse files
committed
Python: Add test for implicit __init__.py files
1 parent 120a569 commit 3d55112

9 files changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
debug_missingAnnotationForCallable
2+
debug_nonUniqueAnnotationForCallable
3+
debug_missingAnnotationForCall
4+
expectedCallEdgeNotFound
5+
| example.py:12:1:12:7 | afunc() | foo/bar/a.py:2:1:2:12 | Function afunc |
6+
unexpectedCallEdgeFound
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CallGraph/PointsTo.ql
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
debug_missingAnnotationForCallable
2+
debug_nonUniqueAnnotationForCallable
3+
debug_missingAnnotationForCall
4+
pointsTo_found_typeTracker_notFound
5+
pointsTo_notFound_typeTracker_found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CallGraph/Relative.ql
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
debug_missingAnnotationForCallable
2+
debug_nonUniqueAnnotationForCallable
3+
debug_missingAnnotationForCall
4+
expectedCallEdgeNotFound
5+
| example.py:12:1:12:7 | afunc() | foo/bar/a.py:2:1:2:12 | Function afunc |
6+
unexpectedCallEdgeFound
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CallGraph/TypeTracker.ql
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
Test that we can resolve callables correctly without using explicit __init__.py files
3+
4+
This is not included in the standard `CallGraph/code` folder, since we're testing our
5+
understanding import work properly, so it's better to have a clean test setup that is
6+
obviously correct (the other one isn't in regards to imports).
7+
8+
Technically this is part of PEP 420 -- Implicit Namespace Packages, but does use the
9+
*real* namespace package feature of allowing source code for a single package to reside
10+
in multiple places.
11+
12+
Since PEP 420 was accepted in Python 3, this test is Python 3 only.
13+
"""
14+
15+
from foo.bar.a import afunc
16+
17+
# calls:afunc
18+
afunc()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# name:afunc
2+
def afunc():
3+
print("afunc called")
4+
return 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: --max-import-depth=1 --lang=3

0 commit comments

Comments
 (0)