diff options
author | Michael Foord <michael@voidspace.org.uk> | 2011-10-08 01:13:25 +0100 |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2011-10-08 01:13:25 +0100 |
commit | 31978ffa59e36b1fe11a19cefe2414843231e662 (patch) | |
tree | b6445be8ea7e480f7e31847b2554231c10b5998b /mock.py | |
parent | d400c6fcc4f6cd04357b49f708cd342633b0c5f2 (diff) | |
download | mock-31978ffa59e36b1fe11a19cefe2414843231e662.tar.gz |
Setting a mock as a return value of itself no longer modifies repr of the mock
Diffstat (limited to 'mock.py')
-rw-r--r-- | mock.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -471,6 +471,14 @@ def _check_and_set_parent(parent, value, name, new_name): (value._mock_new_parent is not None)): return False + _parent = parent + while _parent is not None: + # setting a mock (value) as a child or return value of itself + # should not modify the mock + if _parent is value: + return False + _parent = _parent._mock_new_parent + if new_name: value._mock_new_parent = parent value._mock_new_name = new_name |