Antoine Pitrou added the comment:

I think a better possibility would be to return an indexable "match" object (as 
bit like re match objects):

  my_mock(1, someobj(), bar=someotherobj()):
  match = my_mock.assert_called_with(
      1, ANY, bar=ANY)
  self.assertIsInstance(match[0], someobj)
  self.assertIsInstance(match['bar'], someotherobj)

> It's a *little* cumbersome, but not something I do very often and not
> much extra code. I'm not sure that having "assert_called_with" return
> objects is an intuitive API either. 

It has happened to me quite a bit in the latest days :-)
"assert_called_with" returning something may fall in the "not very pure" 
category, but we already have "assertRaises" and friends returning a context 
manager, and it has proved quite practical.

Also, your proposed workaround wouldn't work for assert_any_call().

Perhaps we should wait for other people to chime in.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17063>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to