Whole file
flexmock/flexmock
The author described this change as “Fix (mostly) handling of mocking parent classes of mocked objects”. It counts as a record because the check below fails on the code as it stood at f854cd9e5 and passes on 5ce178919, with nothing else changed between the two runs.
Projectflexmock/flexmock
Fix saved2011-04-15
Sharing licenceBSD-2-Clause · LICENSE
Change size+5 −3
What the code was meant to do, written into the code itself as a save note
Fix (mostly) handling of mocking parent classes of mocked objects
The change
| 722 | 722 | if hasattr(obj, attr): | |
| 723 | 723 | return | |
| 724 | 724 | for attr in FlexMock.UPDATED_ATTRS: | |
| 725 | - | setattr(obj, attr, getattr(mock, attr)) | |
| 725 | + | if type(obj.__dict__) is dict: | |
| 726 | + | obj.__dict__[attr] = getattr(mock, attr) | |
| 727 | + | else: | |
| 728 | + | setattr(obj, attr, getattr(mock, attr)) | |
| 726 | 729 | except TypeError: | |
| 727 | 730 | raise AttemptingToMockBuiltin | |
| 728 | 731 | ||
| ⋯ | |||
| 730 | 733 | def _get_same_methods(obj): | |
| 731 | 734 | same_methods = [] | |
| 732 | 735 | for attr in FlexMock.UPDATED_ATTRS: | |
| 733 | - | if (hasattr(obj, attr) and | |
| 734 | - | (hasattr(obj, '__class__') and not hasattr(obj.__class__, attr))): | |
| 736 | + | if attr in obj.__dict__: | |
| 735 | 737 | same_methods.append(attr) | |
| 736 | 738 | return same_methods | |
| 737 | 739 | ||
The check that tells the two apart
fail→pass·tests/flexmock_test.py::TestFlexmockUnittest::test_mocking_down_the_inheritance_chain_class_to_class
Check file tests/flexmock_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itf854cd9e575489bb9fcfc0c6a8411d80411bd9cf
Broken version dated2011-04-14
Moduleflexmock
Units changed_attach_flexmock_methods, _get_same_methods
Fingerprint7a32132ed25e6a53
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.