This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients michael.foord, pitrou
Date 2013-01-22.12:15:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1358856947.82.0.71016271567.issue17013@psf.upfronthosting.co.za>
In-reply-to
Content
In non-trivial tests, you may want to wait for a method to be called in another thread. This is a case where unittest.mock currently doesn't help. It would be nice to be able to write:

  myobj.some_method = Mock(side_effect=myobj.some_method)
  # launch some thread
  myobj.some_method.wait_until_called()

And perhaps

  myobj.some_method.wait_until_called_with(...)

(with an optional timeout?)

If we don't want every Mock object to embed a threading.Event, perhaps there could be a ThreadedMock subclass?
Or perhaps even:

  WaitableMock(..., event_class=threading.Event)

so that people can pass multiprocessing.Event if they want to wait on the mock from another process?
History
Date User Action Args
2013-01-22 12:15:47pitrousetrecipients: + pitrou, michael.foord
2013-01-22 12:15:47pitrousetmessageid: <1358856947.82.0.71016271567.issue17013@psf.upfronthosting.co.za>
2013-01-22 12:15:47pitroulinkissue17013 messages
2013-01-22 12:15:47pitroucreate