| 1 |
from textwrap import dedent |
| 2 |
|
| 3 |
|
| 4 |
def get_definition_and_inference_state(Script, source): |
| 5 |
first, = Script(dedent(source)).infer() |
| 6 |
return first._name._value, first._inference_state |
| 7 |
|
| 8 |
|
| 9 |
def test_function_execution(Script): |
| 10 |
""" |
| 11 |
We've been having an issue of a mutable list that was changed inside the |
| 12 |
function execution. Test if an execution always returns the same result. |
| 13 |
""" |
| 14 |
|
| 15 |
s = """ |
| 16 |
def x(): |
| 17 |
return str() |
| 18 |
x""" |
| 19 |
func, inference_state = get_definition_and_inference_state(Script, s) |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
assert len(func.execute_with_values()) == 1 |
| 24 |
assert len(func.execute_with_values()) == 1 |
| 25 |
|
| 26 |
|
| 27 |
def test_class_mro(Script): |
| 28 |
s = """ |
| 29 |
class X(object): |
| 30 |
pass |
| 31 |
X""" |
| 32 |
cls, inference_state = get_definition_and_inference_state(Script, s) |
| 33 |
mro = cls.py__mro__() |
| 34 |
assert [c.name.string_name for c in mro] == ['X', 'object'] |