One function
_Call in testing-cabal/mock
The author described this change as “Fix ANY comparisons with call objects”. It counts as a record because the check below fails on the code as it stood at dca50f78a and passes on 433c78a2c, with nothing else changed between the two runs.
Projecttesting-cabal/mock
Fix saved2012-01-22
Sharing licenceBSD-2-Clause · LICENSE.txt
Change size+2 −0
What the code was meant to do, written into the code itself as a docstring
A tuple for holding the results of a call to a mock, either in the form `(args, kwargs)` or `(name, args, kwargs)`. If args or kwargs are empty then a call tuple will compare equal to a tuple without those values. This makes comparisons less verbose:: _Call(('name', (), {})) == ('name',) _Call(('name', (1,), {})) == ('name', (1,)) _Call(((), {'a': 'b'})) == ({'a': 'b'},) The `_Call` object provides a useful shortcut for comparing with call:: _Call(((1, 2), {'a': 3})) == call(1, 2, a=3) _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3) If the _Call has no name then it will match any name.
The change
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | 60 | def __eq__(self, other): | |
| 61 | + | if other is ANY: | |
| 62 | + | return True | |
| 61 | 63 | try: | |
| 62 | 64 | len(other) | |
| 63 | 65 | except TypeError: |
The check that tells the two apart
fail→pass·tests/testhelpers.py::CallTest::test_call_any
Check file tests/testhelpers.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 itdca50f78ad5c06775690aae2a1bfd5e39c7c950e
Broken version dated2012-01-22
Modulemock
Units changed_Call
Fingerprint3916d96742dea4d2
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in testing-cabal/mock
- 2023-04-16_get_signature_object
- 2022-12-28create_autospec
- 2020-01-29_patch_dict
- 2020-01-29_patch_object
- 2011-07-19Fix callargs call comparisons
- 2011-07-13Fix bug where a failure to create a nested patch could leave patches undone