Roundup Robot added the comment:
New changeset b888c9043566 by Antoine Pitrou in branch 'default':
Issue #17015: When it has a spec, a Mock object now inspects its signature when
matching calls, so that arguments can be matched positionally or by name.
Antoine Pitrou added the comment:
Committed!
--
resolution: - fixed
stage: - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17015
___
Michael Foord added the comment:
Wow, impressive work Antoine - thanks. I am a little concerned that this relies
on Python 3 only features of inspect, and *in fact* relies on bug fixes in
Python 3.4 to work. That means it would be hard / impossible for the backport
mock to have the new
Antoine Pitrou added the comment:
I am a little concerned that this relies on Python 3 only features of
inspect, and *in fact* relies on bug fixes in Python 3.4 to work.
The bug fix has landed in 3.3 as well ;-)
(see 49fd1c8aeca5)
I guess a backport of inspect.signature() would allow it to
Michael Foord added the comment:
Ah, well if the bugfix exists everywhere that function signatures exist then it
shouldn't be a problem. (I think there is already a backport of
inspect.signature() by Nick Coghlan.)
--
___
Python tracker
Changes by Antoine Pitrou pit...@free.fr:
--
dependencies: +Signature.bind() fails with a keyword argument named self
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17015
___
Antoine Pitrou added the comment:
Here is a new patch, making all assert_*_call methods work as well as
autospeccing, and adding tests. Not sure I'm forgetting something else.
--
Added file: http://bugs.python.org/file28903/issue17015-3.patch
___
Antoine Pitrou added the comment:
Proof-of-concept patch. mock is ugly!
--
keywords: +patch
Added file: http://bugs.python.org/file28886/issue17015.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17015
Changes by Éric Araujo mer...@netwok.org:
--
nosy: +eric.araujo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17015
___
___
Python-bugs-list
New submission from Antoine Pitrou:
This is a bit annoying:
def f(a, b): pass
...
mock = Mock(spec=f)
mock(1, 2)
Mock name='mock()' id='140654219634288'
mock.assert_called_with(1, 2)
mock.assert_called_with(a=1, b=2)
Traceback (most recent call last):
File stdin, line 1, in module
Antoine Pitrou added the comment:
(note: also fails if I use `mock = Mock(wraps=f)` instead of `mock =
Mock(spec=f)`)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17015
___
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
nosy: +ezio.melotti
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17015
___
___
12 matches
Mail list logo