[TIP] Testing becomes testing implementation rather than behavioral
mbp at sourcefrog.net
Sun Feb 10 16:11:49 PST 2013
If you need a small number of small files, it's not going to be very slow -
maybe you just actually use real files. testresources will let you reuse
the files across multiple tests. That may be simpler than mocking things,
and as you say it reduces the need for the test to know *how* the function
works - for example the test would probably keep passing even if the
implementation was moved to non-mockable C.
If you are going to mock some IO functions then you can reduce (if not
entirely avoid) the test knowing about the implementations by using mocks
that just set the return values rather than making any assertions or
assumptions about which order things are called.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python