[TIP] how to test "impossible" events

C. Titus Brown ctb at msu.edu
Mon Sep 29 14:23:23 PDT 2008


-> Automated testing though - do I make a mock layer for urllib
-> and for subprocess.Popen?
-> 
-> When I've tried that approach I've found that it takes a lot
-> of time to write, especially as the actual Python code I'm
-> testing is only a few dozen lines, and because I'll have to
-> hand-write those failure cases.

Hi, Andrew,

Yes, I think mocking or dependency injection of some sort is the usual
way to go here.  I *personally* have found that this kind of approach is
very useful -- that is, that doing the extra work to cover the weird
error conditions helps me in the long run -- but I can't really tell
you why.

--titus
-- 
C. Titus Brown, ctb at msu.edu



More information about the testing-in-python mailing list