One function
patch_dict in kaste/mockito-python
The author described this change as “Fail fast for invalid falsy values in patch_dict”. It counts as a record because the check below fails on the code as it stood at 1646c9e96 and passes on 6f7b73aac, with nothing else changed between the two runs.
Projectkaste/mockito-python
Fix saved2026-03-05
Sharing licenceMIT · LICENSE
Change size+1 −1
What the code was meant to do, written into the code itself as a docstring
Patch/update a dict-like object in place. This is a convenience function for test-time dictionary patching, especially for mutable global maps like `os.environ`. Usage:: patch_dict(os.environ, {'USER': 'foo'}) patch_dict(os.environ, [('USER', 'foo')]) patch_dict(os.environ, USER='foo') patch_dict(os.environ, remove={'USER', 'PATH'}) patch_dict(os.environ, remove=all) patch_dict(os.environ, clear=True) patch_dict('os.environ', {'USER': 'foo'}) `with` context management is supported and restores the original mapping state on `__exit__`. `__enter__` returns the patched mapping. `values` can be any value accepted by `dict(values)`. `kwargs` are merged into `values` and take precedence. .. note:: You must :func:`unstub` after patching, or use `with` statement.
The change
| 30 | 30 | else mapping_or_path | |
| 31 | 31 | ) | |
| 32 | 32 | ||
| 33 | - | updates = dict(values or ()) | |
| 33 | + | updates = {} if values is None else dict(values) | |
| 34 | 34 | updates.update(kwargs) | |
| 35 | 35 | return patch_dictionary(mapping, updates, clear=clear, remove=remove) |
The check that tells the two apart
fail→pass·tests/patch_dict_test.py::test_patch_dict_rejects_invalid_falsy_values_argument
Check file tests/patch_dict_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 it1646c9e9693dc49c06d170c7a0ae137b2607302a
Broken version dated2026-03-05
Modulemockito.mockito
Units changedpatch_dict
Fingerprint4234d67733868993
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 kaste/mockito-python
- 2022-06-14mock