[TIP] Pre-empting Fixture execution in Django with nosetests.

Benjamin Scherrey scherrey at proteus-tech.com
Tue Sep 23 01:06:30 PDT 2008


    Here's a fun one for you testing gurus! I have a Django app that uses an
irc server to communicate events to a system. My models utilize the django
model save signal to post an irc message when something is updated. For unit
testing I've been able to monkey-patch the IRC connection object no problem
and everything's dandy. However, most of the tests require fixture objects
so a certain state is established prior to each test. Since fixtures get
loaded prior to my unit test code getting loaded the monkey-patching hasn't
occurred yet and the save signal for the fixture model objects is causing
the system to attempt to talk to a real irc server. According to the Django
documentation I can use settings.TEST_RUNNER to get control of the
fixture/test discovery/execution but this only works for manage.py and is
ignored by nosetests (and its Django plugin).

    Appreciate any ideas...

     -- Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.idyll.org/pipermail/testing-in-python/attachments/20080923/69757460/attachment.html 


More information about the testing-in-python mailing list