Re: Mock object but also assert method calls?

2015-08-15 Thread Thomas Lehmann via Python-list
Am Freitag, 14. August 2015 04:53:56 UTC+2 schrieb Steven D'Aprano: On Fri, 14 Aug 2015 07:21 am, Ben Finney wrote: If find following totally different to the normal API which is provided by the mock library: assert call().test2(hello) in mocked_objects.mock_calls The 'assert'

Re: Mock object but also assert method calls?

2015-08-13 Thread Ben Finney
Thomas Lehmann via Python-list python-list@python.org writes: How about asserting that test2 of class Bar is called? It is unusual to call class methods; do you mean a method on an instance? You will make a mock instance of the class, or a mock of the class; and you'll need to know which it

Re: Mock object but also assert method calls?

2015-08-13 Thread Steven D'Aprano
On Fri, 14 Aug 2015 07:21 am, Ben Finney wrote: If find following totally different to the normal API which is provided by the mock library: assert call().test2(hello) in mocked_objects.mock_calls The ‘assert’ statement is a crude tool, which knows little about the intent of your

Mock object but also assert method calls?

2015-08-13 Thread Thomas Lehmann via Python-list
Hi, How about asserting that test2 of class Bar is called? Of course I can do a patch for a concrete method but I was looking for something like: mocked_object.assert_method_called_with(name=test2, hello) If find following totally different to the normal API which is provided by the mock