mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Python: Add import regression for if-then-else definitions
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from trace import *
|
||||
enter(__file__)
|
||||
|
||||
# definition based on "random" choice in this case it will always go the the if-branch,
|
||||
# but our analysis is not able to figure this out
|
||||
if eval("True"):
|
||||
if_then_else_defined = "if_defined"
|
||||
else:
|
||||
# we also check that nested if-then-else works, it would be easy to accidentally
|
||||
# only support _one_ level of nesting.
|
||||
if eval("True"):
|
||||
if_then_else_defined = "else_defined_1"
|
||||
else:
|
||||
if_then_else_defined = "else_defined_2"
|
||||
|
||||
exit(__file__)
|
||||
@@ -89,6 +89,9 @@ check("non_clashing_submodule", non_clashing_submodule, "<module attr_clash.non_
|
||||
from package.subpackage2 import *
|
||||
check("subpackage2_attr", subpackage2_attr, "subpackage2_attr", globals()) #$ prints=subpackage2_attr
|
||||
|
||||
# check that definitions from within if-then-else are found
|
||||
from if_then_else import if_then_else_defined
|
||||
check("if_then_else_defined", if_then_else_defined, "if_defined", globals()) #$ MISSING: prints=if_defined prints=else_defined_1 prints=else_defined_2
|
||||
|
||||
exit(__file__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user