mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
QL tests for Python queries and libraries.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
| multiple_del.py:17:1:17:17 | class Y3 | Class Y3 may not be cleaned up properly as $@ may be called multiple times during destruction. | multiple_del.py:9:5:9:22 | Function __del__ | method Y1.__del__ |
|
||||
| multiple_del.py:34:1:34:17 | class Z3 | Class Z3 may not be cleaned up properly as $@ may be called multiple times during destruction. | multiple_del.py:26:5:26:22 | Function __del__ | method Z1.__del__ |
|
||||
@@ -0,0 +1 @@
|
||||
Classes/SuperclassDelCalledMultipleTimes.ql
|
||||
@@ -0,0 +1,2 @@
|
||||
| multiple_init.py:17:1:17:17 | class C3 | Class C3 may not be initialized properly as $@ may be called multiple times during initialization. | multiple_init.py:9:5:9:23 | Function __init__ | method C1.__init__ |
|
||||
| multiple_init.py:34:1:34:17 | class D3 | Class D3 may not be initialized properly as $@ may be called multiple times during initialization. | multiple_init.py:26:5:26:23 | Function __init__ | method D1.__init__ |
|
||||
@@ -0,0 +1 @@
|
||||
Classes/SuperclassInitCalledMultipleTimes.ql
|
||||
38
python/ql/test/query-tests/Classes/multiple/multiple_del.py
Normal file
38
python/ql/test/query-tests/Classes/multiple/multiple_del.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#Calling a method multiple times by using explicit calls when a base uses super()
|
||||
class Base(object):
|
||||
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
class Y1(Base):
|
||||
|
||||
def __del__(self):
|
||||
super(Y1, self).__del__()
|
||||
|
||||
class Y2(Base):
|
||||
|
||||
def __del__(self):
|
||||
super(Y2, self).__del__() #When `type(self) == Y3` this calls `Y1.__del__`
|
||||
|
||||
class Y3(Y2, Y1):
|
||||
|
||||
def __del__(self):
|
||||
Y1.__del__(self)
|
||||
Y2.__del__(self)
|
||||
|
||||
#Calling a method multiple times by using explicit calls when a base inherits from other base
|
||||
class Z1(object):
|
||||
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
class Z2(Z1):
|
||||
|
||||
def __del__(self):
|
||||
Z1.__del__(self)
|
||||
|
||||
class Z3(Z2, Z1):
|
||||
|
||||
def __del__(self):
|
||||
Z1.__del__(self)
|
||||
Z2.__del__(self)
|
||||
76
python/ql/test/query-tests/Classes/multiple/multiple_init.py
Normal file
76
python/ql/test/query-tests/Classes/multiple/multiple_init.py
Normal file
@@ -0,0 +1,76 @@
|
||||
#Calling a method multiple times by using explicit calls when a base uses super()
|
||||
class Base(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
class C1(Base):
|
||||
|
||||
def __init__(self):
|
||||
super(C1, self).__init__()
|
||||
|
||||
class C2(Base):
|
||||
|
||||
def __init__(self):
|
||||
super(C2, self).__init__() #When `type(self) == C3` this calls `C1.__init__`
|
||||
|
||||
class C3(C2, C1):
|
||||
|
||||
def __init__(self):
|
||||
C1.__init__(self)
|
||||
C2.__init__(self)
|
||||
|
||||
#Calling a method multiple times by using explicit calls when a base inherits from other base
|
||||
class D1(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
class D2(D1):
|
||||
|
||||
def __init__(self):
|
||||
D1.__init__(self)
|
||||
|
||||
class D3(D2, D1):
|
||||
|
||||
def __init__(self):
|
||||
D1.__init__(self)
|
||||
D2.__init__(self)
|
||||
|
||||
#OK to call object.__init__ multiple times
|
||||
class E1(object):
|
||||
|
||||
def __init__(self):
|
||||
super(E1, self).__init__()
|
||||
|
||||
class E2(object):
|
||||
|
||||
def __init__(self):
|
||||
object.__init__(self)
|
||||
|
||||
class E3(E2, E1):
|
||||
|
||||
def __init__(self):
|
||||
E1.__init__(self)
|
||||
E2.__init__(self)
|
||||
|
||||
#Two invocations, but can only be called once
|
||||
class F1(Base):
|
||||
|
||||
def __init__(self, cond):
|
||||
if cond:
|
||||
Base.__init__(self)
|
||||
else:
|
||||
Base.__init__(self)
|
||||
|
||||
#Single call, splitting causes what seems to be multiple invocations.
|
||||
class F2(Base):
|
||||
|
||||
def __init__(self, cond):
|
||||
if cond:
|
||||
pass
|
||||
if cond:
|
||||
pass
|
||||
Base.__init__(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user