Object Attributes Side Effects

After this change Pythoscope should be able to trace this code:

class Something:
    def some_method(self):
        self.attr = 42

and generate a following test case:

def test_some_method(self):
    something = Something()
    assert_equal(None, something.some_method())
    assert_equal(42, something.attr)

In other words, Pythoscope should also assert all attribute changes, in addition to return values of methods.

Implementation note

This describes a side effect, so all attributes of UserObjects should be handled by SharedState.

Implementation note #2

Function calls are no different than method calls.

Objects can be changed by any call, to any method or function, if it appears in the argument list, regardless of its position in that list. Of course, passing an object as an argument doesn't mean it was modified in a given call, it only reveals a possibility. Deciding whether given call was relevant or not, is a problem of tracing side effects.

Anyway, keep in mind that a test of object state changes can include not only calls to its own methods, but also calls to methods of other objects and functions.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License