[TIP] py.test + mock - how to test attribute "call"?
moagstar at gmail.com
Wed Nov 2 11:10:56 PDT 2016
Hi Sylvain, perhaps the responses library might be of use to you for
mocking the requests library
On Nov 2, 2016 12:50 PM, "Sylvain Viart" <sylvain at opensource-expert.com>
> I didn't find the answer yet, but I tested another approach with httmock
> I also gonna explore setting up an instance of powerdns to have a fully
> testable environment.
> I you still have mocking / testing suggestion I'm interested.
> Nothing under this citation, new version has been commited, links may be
> I'm having trouble to understand how to use correctly mock object to test
> correctness of requests' call and also returned object.
> I'm using py.test + pytest-mock
> I would like to test here that r.text is returned if I call:
> r = p.exec_pdns_api('GET', rest_url, text=True)
> how to I make an assertion that the r.text has been called/returned?
> r is <MagicMock name='get().text' id='139703066450704'>
> r.text.assert_called() is not the good assertion
> test code here: https://github.com/opensource-
> Sylvain Viart - DevOps système linux - freelance developer
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python