[TIP] Testing becomes testing implementation rather than behavioral
wjwxinst at gmail.com
Sun Feb 10 14:55:30 PST 2013
Suppose I have this piece of code:
def some_func(parm1, parm2, ....):
// do a bunch of os operation using shutil, os, and some other
custom libraries (hashing, etc)
So if I want to write a unittest, I'd mock out os.path.exists and just
about everything in this function! That's testing against implementation
rather than the behavioral of the function (does the output matches the
In some cases, I can put everything complex into individual functiosn
def some_func(parm1, parm2....):
But I still have to test func1 and func2. So at the end of the day, I still
have to mock many things out.
How would do test it? I know I can setup some fixture data like real files,
but that's slow. I might as well just write an integration test and forget
about my unittest, but that could run a long time.
Thanks a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python