[TIP] Problem with mock
Julian Berman
julian at grayvines.com
Thu Dec 20 18:38:18 PST 2012
On Thursday, December 20, 2012, Ken Hagler wrote:
>
> > So, if you want to have a config attr, you have to set it, presumably to
> a
> > mock object
>
> Okay, how? If mocking super is useless, than how to I get that to happen?
Well, like I said it's not useless if you don't want the super upcall to
run. But it's not sufficient.
Set a mock like any other attribute. Here it's a bit uglier since you need
to mock a thing that should be set in __init__ while you're testing
__init__'s behavior, but I guess you'd do
with mock.patch.object(DevBuild, "config") as config:
self.d = DevBuild(whatever)
config.assert_whatever()
in addition to the super mock.
Cheers,
Julian
--
> Ken Hagler
>
> | http://www.orange-road.com/ |
> | And tho' we are not now that strength which in old days |
> | Moved earth and heaven, that which we are, we are --Tennyson |
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20121220/a6471d8c/attachment.htm>
More information about the testing-in-python
mailing list