Skip to content

Commit f71cf2e

Browse files
authored
Python: Add test
1 parent 60eb341 commit f71cf2e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

python/ql/test/experimental/dataflow/typetracking/attribute_tests.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ def test_create_with_foo():
4949
x = create_with_foo() # $ tracked=foo
5050
print(x.foo) # $ tracked=foo tracked
5151

52+
def test_global_attribute_assignment():
53+
global global_var
54+
global_var.foo = tracked # $ tracked tracked=foo
55+
56+
def test_global_attribute_read():
57+
x = global_var.foo # $ MISSING: tracked tracked=foo
58+
59+
def test_local_attribute_assignment():
60+
# Same as `test_global_attribute_assignment`, but the assigned variable is not global
61+
local_var = object() # $ tracked=foo
62+
local_var.foo = tracked # $ tracked tracked=foo
63+
64+
def test_local_attribute_read():
65+
x = local_var.foo
66+
67+
5268
# ------------------------------------------------------------------------------
5369
# Attributes assigned statically to a class
5470
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)