Skip to content

Commit 5f32f89

Browse files
committed
Python: API-graphs: test class decorators and subclass
A class decorator could change the class definition in any way. In this specific case, it would be better if we allowed the subclass to be found with API graphs still. inspired by https://github.com/django/django/blob/c2250cfb80e27cdf8d098428824da2800a18cadf/tests/auth_tests/test_views.py#L40-L46
1 parent b2c8e0f commit 5f32f89

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

python/ql/test/library-tests/ApiGraphs/py3/deftest2.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,19 @@ class IntMyView(View): #$ use=moduleImport("pflask").getMember("views").getMembe
1616
def my_internal_method(self): #$ def=moduleImport("pflask").getMember("views").getMember("View").getASubclass().getMember("my_internal_method")
1717
pass
1818

19-
int_instance = IntMyView() #$ use=moduleImport("pflask").getMember("views").getMember("View").getASubclass().getReturn()
19+
int_instance = IntMyView() #$ use=moduleImport("pflask").getMember("views").getMember("View").getASubclass().getReturn()
20+
21+
# ------------------------------------------------------------------------------
22+
# Class decorator
23+
# ------------------------------------------------------------------------------
24+
25+
def my_class_decorator(cls):
26+
print("dummy decorator")
27+
return cls
28+
29+
@my_class_decorator
30+
class MyViewWithDecorator(View): #$ use=moduleImport("flask").getMember("views").getMember("View").getASubclass()
31+
pass
32+
33+
class SubclassFromDecorated(MyViewWithDecorator): #$ MISSING: use=moduleImport("flask").getMember("views").getMember("View").getASubclass().getASubclass()
34+
pass

0 commit comments

Comments
 (0)