[issue22138] patch.object doesn't restore function defaults
Clint Hepner
report at bugs.python.org
Tue Aug 5 06:14:00 CEST 2014
New submission from Clint Hepner:
Following a patch, a function's __defaults__ attribute is reset to None.
def foo(x=5):
return x
assert foo() == 5 # As expected
with unittest.mock.patch.object(foo, '__defaults__', (10,)):
assert foo() == 10 # As expected
assert foo() == 5 # Fails
assert foo.__defaults__ is None # Succeeds
----------
components: Library (Lib)
messages: 224801
nosy: chepner
priority: normal
severity: normal
status: open
title: patch.object doesn't restore function defaults
type: behavior
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22138>
_______________________________________
More information about the Python-bugs-list
mailing list