[TIP] Parametrize tests for unit or integration testing

Mateusz Łoskot mateusz at loskot.net
Sat Feb 1 13:16:25 PST 2014


This is my first post here, so hello everyone.

I was searching through the list archives and I stumbled upon this post
in which Benji mentions about writing
"a parameterized test and apply the same test twice.  Once in an
environment where the "real" thing is used and once where the "stub" is used"

AFAIU, the idea is to write test(s) once, then parametrize for use in both
modes, as unit tests or integration tests.

Could anyone explain or give example how to implement
such parametrization?
Perhaps Benji is still around and could explain the original technique?

I'm using Python 3.2 or 3.3 and I write my tests using
unittest and mock (or unittest.mock) modules.
So, I'm interested in using those to to achieve the parametrized
tests for unit/integration testing modes.

Best regards,
Mateusz  Łoskot, http://mateusz.loskot.net

More information about the testing-in-python mailing list