[TIP] Testing becomes testing implementation rather than behavioral

Martin Pool 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...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130211/68c88597/attachment-0001.htm>


More information about the testing-in-python mailing list