[openstack-dev] [Neutron][qa] The 'spec' parameter of mock.patch()

Maru Newby marun at redhat.com
Fri Jan 10 21:20:24 UTC 2014


I recently saw a case [1] where a misspelled assertion method (asoptt_called_once_with vs assert_called_once_with) did not result in a test failure because the object it was called on was created by mock.patch() without any of the spec/spec_set/autospec parameters being set.  Might it make sense to require that calls to mock.patch() set autospec=True [2]?


m.

1: https://review.openstack.org/#/c/61105/7/neutron/tests/unit/openvswitch/test_ovs_lib.py (line 162)
2: http://www.voidspace.org.uk/python/mock/patch.html#mock.patch




More information about the OpenStack-dev mailing list