-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: split tests for Functions into more files
Makes it easier to see what the testcases are relevant for what queries.
- Loading branch information
Showing
9 changed files
with
140 additions
and
138 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
python/ql/test/query-tests/Functions/general/DeprecatedSliceMethod.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
| functions_test.py:200:5:200:40 | Function __getslice__ | __getslice__ method has been deprecated since Python 2.0 | | ||
| functions_test.py:203:5:203:47 | Function __setslice__ | __setslice__ method has been deprecated since Python 2.0 | | ||
| functions_test.py:206:5:206:40 | Function __delslice__ | __delslice__ method has been deprecated since Python 2.0 | | ||
| functions_test.py:99:5:99:40 | Function __getslice__ | __getslice__ method has been deprecated since Python 2.0 | | ||
| functions_test.py:102:5:102:47 | Function __setslice__ | __setslice__ method has been deprecated since Python 2.0 | | ||
| functions_test.py:105:5:105:40 | Function __delslice__ | __delslice__ method has been deprecated since Python 2.0 | |
2 changes: 1 addition & 1 deletion
2
python/ql/test/query-tests/Functions/general/ExplicitReturnInInit.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
| functions_test.py:45:9:45:19 | Return | Explicit return in __init__ method. | | ||
| explicit_return_in_init.py:4:9:4:19 | Return | Explicit return in __init__ method. | |
2 changes: 1 addition & 1 deletion
2
python/ql/test/query-tests/Functions/general/InitIsGenerator.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
| functions_test.py:73:5:73:23 | Function __init__ | __init__ method is a generator. | | ||
| explicit_return_in_init.py:32:5:32:23 | Function __init__ | __init__ method is a generator. | |
20 changes: 10 additions & 10 deletions
20
python/ql/test/query-tests/Functions/general/ModificationOfParameterWithDefault.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
edges | ||
| functions_test.py:39:9:39:9 | empty mutable value | functions_test.py:40:5:40:5 | empty mutable value | | ||
| functions_test.py:238:15:238:15 | empty mutable value | functions_test.py:239:5:239:5 | empty mutable value | | ||
| functions_test.py:290:25:290:25 | empty mutable value | functions_test.py:291:5:291:5 | empty mutable value | | ||
| functions_test.py:293:21:293:21 | empty mutable value | functions_test.py:294:5:294:5 | empty mutable value | | ||
| functions_test.py:296:27:296:27 | empty mutable value | functions_test.py:297:25:297:25 | empty mutable value | | ||
| functions_test.py:296:27:296:27 | empty mutable value | functions_test.py:298:21:298:21 | empty mutable value | | ||
| functions_test.py:297:25:297:25 | empty mutable value | functions_test.py:290:25:290:25 | empty mutable value | | ||
| functions_test.py:298:21:298:21 | empty mutable value | functions_test.py:293:21:293:21 | empty mutable value | | ||
| functions_test.py:133:15:133:15 | empty mutable value | functions_test.py:134:5:134:5 | empty mutable value | | ||
| functions_test.py:185:25:185:25 | empty mutable value | functions_test.py:186:5:186:5 | empty mutable value | | ||
| functions_test.py:188:21:188:21 | empty mutable value | functions_test.py:189:5:189:5 | empty mutable value | | ||
| functions_test.py:191:27:191:27 | empty mutable value | functions_test.py:192:25:192:25 | empty mutable value | | ||
| functions_test.py:191:27:191:27 | empty mutable value | functions_test.py:193:21:193:21 | empty mutable value | | ||
| functions_test.py:192:25:192:25 | empty mutable value | functions_test.py:185:25:185:25 | empty mutable value | | ||
| functions_test.py:193:21:193:21 | empty mutable value | functions_test.py:188:21:188:21 | empty mutable value | | ||
#select | ||
| functions_test.py:40:5:40:5 | x | functions_test.py:39:9:39:9 | empty mutable value | functions_test.py:40:5:40:5 | empty mutable value | $@ flows to here and is mutated. | functions_test.py:39:9:39:9 | x | Default value | | ||
| functions_test.py:239:5:239:5 | x | functions_test.py:238:15:238:15 | empty mutable value | functions_test.py:239:5:239:5 | empty mutable value | $@ flows to here and is mutated. | functions_test.py:238:15:238:15 | x | Default value | | ||
| functions_test.py:291:5:291:5 | x | functions_test.py:296:27:296:27 | empty mutable value | functions_test.py:291:5:291:5 | empty mutable value | $@ flows to here and is mutated. | functions_test.py:296:27:296:27 | y | Default value | | ||
| functions_test.py:294:5:294:5 | x | functions_test.py:296:27:296:27 | empty mutable value | functions_test.py:294:5:294:5 | empty mutable value | $@ flows to here and is mutated. | functions_test.py:296:27:296:27 | y | Default value | | ||
| functions_test.py:134:5:134:5 | x | functions_test.py:133:15:133:15 | empty mutable value | functions_test.py:134:5:134:5 | empty mutable value | $@ flows to here and is mutated. | functions_test.py:133:15:133:15 | x | Default value | | ||
| functions_test.py:186:5:186:5 | x | functions_test.py:191:27:191:27 | empty mutable value | functions_test.py:186:5:186:5 | empty mutable value | $@ flows to here and is mutated. | functions_test.py:191:27:191:27 | y | Default value | | ||
| functions_test.py:189:5:189:5 | x | functions_test.py:191:27:191:27 | empty mutable value | functions_test.py:189:5:189:5 | empty mutable value | $@ flows to here and is mutated. | functions_test.py:191:27:191:27 | y | Default value | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
| functions_test.py:100:5:100:24 | Function n_cmethod | Class methods or methods of a type deriving from type should have 'cls', rather than 'self', as their first argument. | | ||
| functions_test.py:114:5:114:20 | Function c_method | Class methods or methods of a type deriving from type should have 'cls', rather than 'y', as their first argument. | | ||
| argument_names.py:17:5:17:24 | Function n_cmethod | Class methods or methods of a type deriving from type should have 'cls', rather than 'self', as their first argument. | | ||
| argument_names.py:32:5:32:20 | Function c_method | Class methods or methods of a type deriving from type should have 'cls', rather than 'y', as their first argument. | |
4 changes: 2 additions & 2 deletions
4
python/ql/test/query-tests/Functions/general/NonSelf.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
| functions_test.py:130:5:130:20 | Function __init__ | Normal methods should have 'self', rather than 'x', as their first parameter. | | ||
| functions_test.py:133:5:133:20 | Function s_method | Normal methods should have 'self', rather than 'y', as their first parameter. | | ||
| argument_names.py:45:5:45:20 | Function __init__ | Normal methods should have 'self', rather than 'x', as their first parameter. | | ||
| argument_names.py:48:5:48:20 | Function s_method | Normal methods should have 'self', rather than 'y', as their first parameter. | | ||
| om_test.py:71:5:71:19 | Function __repr__ | Normal methods should have at least one parameter (the first of which should be 'self'). | |
68 changes: 68 additions & 0 deletions
68
python/ql/test/query-tests/Functions/general/argument_names.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Using name other than 'self' for first argument in methods. | ||
# This shouldn't apply to classmethods (first argument should be 'cls' or similar) | ||
# or static methods (first argument can be anything) | ||
|
||
|
||
class Normal(object): | ||
|
||
def n_ok(self): | ||
pass | ||
|
||
@staticmethod | ||
def n_smethod(ok): | ||
pass | ||
|
||
# not ok | ||
@classmethod | ||
def n_cmethod(self): | ||
pass | ||
|
||
# this is allowed because it has a decorator other than @classmethod | ||
@classmethod | ||
@id | ||
def n_suppress(any_name): | ||
pass | ||
|
||
|
||
class Class(type): | ||
|
||
def __init__(cls): | ||
pass | ||
|
||
def c_method(y): | ||
pass | ||
|
||
def c_ok(cls): | ||
pass | ||
|
||
@id | ||
def c_suppress(any_name): | ||
pass | ||
|
||
|
||
class NonSelf(object): | ||
|
||
def __init__(x): | ||
pass | ||
|
||
def s_method(y): | ||
pass | ||
|
||
def s_ok(self): | ||
pass | ||
|
||
@staticmethod | ||
def s_smethod(ok): | ||
pass | ||
|
||
@classmethod | ||
def s_cmethod(cls): | ||
pass | ||
|
||
def s_smethod2(ok): | ||
pass | ||
s_smethod2 = staticmethod(s_smethod2) | ||
|
||
def s_cmethod2(cls): | ||
pass | ||
s_cmethod2 = classmethod(s_cmethod2) |
39 changes: 39 additions & 0 deletions
39
python/ql/test/query-tests/Functions/general/explicit_return_in_init.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class ExplicitReturnInInit(object): | ||
|
||
def __init__(self): | ||
return self | ||
|
||
#These are OK | ||
class ExplicitReturnNoneInInit(object): | ||
|
||
def __init__(self): | ||
return None | ||
|
||
class PlainReturnInInit(object): | ||
|
||
def __init__(self): | ||
return | ||
|
||
def error(): | ||
raise Exception() | ||
|
||
class InitCallsError(object): | ||
|
||
def __init__(self): | ||
return error() | ||
|
||
class InitCallsInit(InitCallsError): | ||
|
||
def __init__(self): | ||
return InitCallsError.__init__(self) | ||
|
||
class InitIsGenerator(object): | ||
|
||
def __init__(self): | ||
yield self | ||
|
||
#OK as it returns result of a call to super().__init__() | ||
class InitCallsInit(InitCallsError): | ||
|
||
def __init__(self): | ||
return super(InitCallsInit, self).__init__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters