[TIP] strange mock behaviour

andrea crotti andrea.crotti.0 at gmail.com
Thu Jun 13 01:48:23 PDT 2013


I figured it out in the end.
Basically the module I wanted to patch had the same name of a package that
was imported in __init__.py.

This made the name clash and mock was getting confused of coursre,


2013/6/12 andrea crotti <andrea.crotti.0 at gmail.com>

> I'm having a strange issue with Mock (version 1.0.1) that I've never
> noticed before
>
> So I have a patch in this form:
>     @patch('app.notifications.create_notification')
>     def test_challenge_ended_going_in_review(self, fake_create):
>
>
> but I get an error from that same test complaining about:
> AttributeError: <module 'app.handlers.notifications' from
> '/home/andrea/wazoku/wazoku/wazoku-api/api/app/handlers/notifications/__init__.pyc'>
> does not have the attribute 'create_notification'
>
> but I can't figure how and why it adds the "handlers" in between..
> app/notifications.py is a perfectly normal module, what could be messing
> up things?
>
> Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130613/48875e4c/attachment.html>


More information about the testing-in-python mailing list