[issue17013] Allow waiting on a mock

2020-06-10 Thread Ilya Kulakov
Ilya Kulakov added the comment: > That is not true, is actually encouraged to check for singletons like True, > False and None. You're right, just never used it as I never needed an identity check against True / False The PR is re-done to use an additional property call_event instead of

[issue17013] Allow waiting on a mock

2020-06-10 Thread Ilya Kulakov
Ilya Kulakov added the comment: As far as I understand it introduces 3 methods that may clash. It's unlikely but (I speculate) is still more likely than an identity check with called. That being said, the PR can be redone as a subclass. But that implementation will not play as nicely with

[issue17013] Allow waiting on a mock

2020-06-10 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Current implementation relies on that: Notice that this is a clear disadvantage over a subclass-based approach, which is backwards compatible and preserves the semantics of mock. -- ___ Python tracker

[issue17013] Allow waiting on a mock

2020-06-10 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > 1. called is almost never used in practice (people just use .assert*) Sorry but saying "almost never used" is not good enough. Not only because you hold incomplete data but because backwards compatibility is mainly binary: it breaks or it does not,

[issue17013] Allow waiting on a mock

2020-06-10 Thread Ilya Kulakov
Ilya Kulakov added the comment: > Unfortunately, we take backwards compatibility very seriously in the core > team and this is a big downside of this proposal. Current implementation relies on that: 1. called is almost never used in practice (people just use .assert*) 2. The is True / False

[issue17013] Allow waiting on a mock

2020-06-10 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Correct, it is not backward compatible in that respect. Unfortunately, we take backwards compatibility very seriously in the core team and this is a big downside of this proposal. > I can instead add the called_event property Wouldn't that also

[issue17013] Allow waiting on a mock

2020-06-10 Thread Ilya Kulakov
Ilya Kulakov added the comment: Correct, it is not backward compatible in that respect. I did not check thoroughly, but a quick lookup shown no such use among public repos on GitHub. I can instead add the called_event property and make the CallEvent “public”. Best Regards Ilya Kulakov > On

[issue17013] Allow waiting on a mock

2020-06-09 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: isn't PR 20759 backwards incompatible? If I understand correctly, this would break anyone that is checking for identity as : assert mymock.called is True -- nosy: +pablogsal ___ Python tracker

[issue17013] Allow waiting on a mock

2020-06-09 Thread Ilya Kulakov
Change by Ilya Kulakov : -- nosy: +Ilya.Kulakov nosy_count: 11.0 -> 12.0 pull_requests: +19958 pull_request: https://github.com/python/cpython/pull/20759 ___ Python tracker

[issue17013] Allow waiting on a mock

2020-04-27 Thread Mario Corchero
Mario Corchero added the comment: For the record, I have no strong preference over either implementation. @voidspace preferred offline the new mock class, but sadly the rationale is lost in the physical word. -- ___ Python tracker

[issue17013] Allow waiting on a mock

2020-01-10 Thread Cheryl Sabella
Change by Cheryl Sabella : -- versions: +Python 3.9 -Python 3.8 ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue17013] Allow waiting on a mock

2019-11-18 Thread Ilya Kulakov
Ilya Kulakov added the comment: I have submitted an alternative implementation of this feature heavily inspired by _AwaitEvent I wrote for asynctest [0]. There was recently an interest from the community towards asynctest to the point that got some of its measures merged into CPython [1].

[issue17013] Allow waiting on a mock

2019-11-12 Thread Ilya Kulakov
Change by Ilya Kulakov : -- pull_requests: +16643 pull_request: https://github.com/python/cpython/pull/17133 ___ Python tracker ___

[issue17013] Allow waiting on a mock

2019-09-13 Thread Mario Corchero
Change by Mario Corchero : -- pull_requests: +15715 pull_request: https://github.com/python/cpython/pull/16094 ___ Python tracker ___

[issue17013] Allow waiting on a mock

2019-09-12 Thread Mario Corchero
Mario Corchero added the comment: Spoke offline with @xtreak, I'll be sending a PR for this to take over the existing one. @lisroach proposed a new name, EventMock to differentiate it from any awaitable async notation. @michael.foord suggested using `mock_timeout` as the argument.

[issue17013] Allow waiting on a mock

2019-09-12 Thread Lisa Roach
Change by Lisa Roach : -- nosy: +lisroach ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue17013] Allow waiting on a mock

2019-04-14 Thread László Kiss Kollár
Change by László Kiss Kollár : -- nosy: +lkollar ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue17013] Allow waiting on a mock

2019-04-13 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- keywords: +patch pull_requests: +12743 stage: needs patch -> patch review ___ Python tracker ___

[issue17013] Allow waiting on a mock

2019-04-13 Thread Mario Corchero
Mario Corchero added the comment: Kooning great! I would Add a test for the following (I think both fails with the proposed impl): - The mock is called BEFORE calling wait_until_called_with - I call the mock with arguments and then I call wait for call without arguments. - using keyword

[issue17013] Allow waiting on a mock

2019-04-13 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks Mario for the feedback. > I see you inherit from Mock, should it inherit from MagicMock? yes, it can inherit from MagicMock to mock magic methods and to wait on their call. I thought some more about waiting for function call with

[issue17013] Allow waiting on a mock

2019-04-13 Thread Mario Corchero
Mario Corchero added the comment: I think this is REALLY interesting!, there are many situations where this has been useful, it would greatly improve multithreading testing in Python. Q? I see you inherit from Mock, should it inherit from MagicMock? I'd say send the PR and the discussion can

[issue17013] Allow waiting on a mock

2019-04-13 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Is there still sufficient interest in this? I gave an initial try at this based on my limited knowledge of mock and Antoine's idea. I created a new class WaitableMock that inherits from Mock and accepts an event_class with threading.Event as

[issue17013] Allow waiting on a mock

2017-12-11 Thread Cheryl Sabella
Change by Cheryl Sabella : -- stage: -> needs patch versions: +Python 3.8 -Python 3.4 ___ Python tracker ___

[issue17013] Allow waiting on a mock

2015-07-31 Thread Robert Collins
Robert Collins added the comment: Now at https://github.com/testing-cabal/mock/issues/189 -- nosy: +rbcollins ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17013 ___

[issue17013] Allow waiting on a mock

2013-02-04 Thread Michael Foord
Michael Foord added the comment: There is a similar feature request on the mock issue tracker: http://code.google.com/p/mock/issues/detail?id=189 I prefer this proposal to the other one though. (Although technically allowing a wait for multiple calls is more flexible.) --

[issue17013] Allow waiting on a mock

2013-01-22 Thread Antoine Pitrou
New submission from Antoine Pitrou: 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

[issue17013] Allow waiting on a mock

2013-01-22 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17013 ___ ___

[issue17013] Allow waiting on a mock

2013-01-22 Thread Jesús Cea Avión
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17013 ___ ___ Python-bugs-list mailing list