PythonExectuor doesn't work with decorated functions
For the default model generated with:
$ altwalker init test-project -l python
And the following test code:
# tests/test.py
import functools
def decorator_without_args(func):
@functools.wraps(func)
def _wrapper(*args, **kwargs):
print("Decorated function.")
fun(*args, *kwargs)
return _wrapper
def decorator_with_args(*args, **kwargs):
def _decorator(func):
@functools.wraps(func)
def _wrapper(*args, **kwargs):
print("Decorated function.")
func(*args, **kargs)
return _wrapper
return _decorator
class ModelName:
@decorator_without_args
def vertex_A(self):
pass
def vertex_B(self):
pass
def edge_A(self):
pass
And then run the tests:
$ altwalker online tests -m models/default.json "random(vertex_coverage(100))" Running:
[2019-11-15 14:29:40.399111] ModelName.vertex_A Running
[2019-11-15 14:29:40.409292] Unexpected error ocurrent while running ModelName.vertex_A.
Error: The ModelName.vertex_A method must take 0 or 1 parameters but it expects -1 parameters.
Traceback (most recent call last):
File "/Users/robert/Documents/gitlab/altwalker/altwalker/walker.py", line 144, in _run_step
status = self._execute_step(step)
File "/Users/robert/Documents/gitlab/altwalker/altwalker/walker.py", line 123, in _execute_step
result = self._executor.execute_step(step.get("modelName"), step.get("name"), data_before)
File "/Users/robert/Documents/gitlab/altwalker/altwalker/executor.py", line 440, in execute_step
raise ExecutorException(error_message.format(func_name, type_, 0, 1, nr_args))
altwalker.exceptions.ExecutorException: The ModelName.vertex_A method must take 0 or 1 parameters but it expects -1 parameters.
Statistics:
Model Coverage....................0%
Number of Models...................1
Completed Models...................0
Failed Models......................1
Incomplete Models..................0
Not Executed Models................0
Edge Coverage.....................0%
Number of Edges....................1
Visited Edges......................0
Unvisited Edges....................1
Vertex Coverage..................50%
Number of Vertices.................2
Visited Vertices...................1
Unvisited Vertices.................1
Status: FAIL
If you change vertex_A
to use the @decorator_with_args
the same problem appears:
@decorator_with_args("arg")
def vertex_A(self):
pass
And then run the tests:
$ altwalker online tests -m models/default.json "random(vertex_coverage(100))"
Running:
[2019-11-15 14:35:37.249049] ModelName.vertex_A Running
[2019-11-15 14:35:37.258244] Unexpected error ocurrent while running ModelName.vertex_A.
Error: The ModelName.vertex_A method must take 0 or 1 parameters but it expects -1 parameters.
Traceback (most recent call last):
File "/Users/robert/Documents/gitlab/altwalker/altwalker/walker.py", line 144, in _run_step
status = self._execute_step(step)
File "/Users/robert/Documents/gitlab/altwalker/altwalker/walker.py", line 123, in _execute_step
result = self._executor.execute_step(step.get("modelName"), step.get("name"), data_before)
File "/Users/robert/Documents/gitlab/altwalker/altwalker/executor.py", line 440, in execute_step
raise ExecutorException(error_message.format(func_name, type_, 0, 1, nr_args))
altwalker.exceptions.ExecutorException: The ModelName.vertex_A method must take 0 or 1 parameters but it expects -1 parameters.
Statistics:
Model Coverage....................0%
Number of Models...................1
Completed Models...................0
Failed Models......................1
Incomplete Models..................0
Not Executed Models................0
Edge Coverage.....................0%
Number of Edges....................1
Visited Edges......................0
Unvisited Edges....................1
Vertex Coverage..................50%
Number of Vertices.................2
Visited Vertices...................1
Unvisited Vertices.................1
Status: FAIL
Resources
Edited by Robert Dezmerean