[TIP] [python] Re: Mock Testing Patterns
gustavo at niemeyer.net
Mon Nov 19 08:38:04 PST 2007
> I use the same pattern as Michael, and find it works just fine with Dave
> Kirby's python-mock (located at http://python-mock.sourceforge.net/).
> (Okay, I've modified it a little to also take a dictionary of
> param->return value mappings, but it's a trivial modification.)
Interesting. I'm curious about how easy it is to perform certain tasks:
1. How does it verify that no *unexpected* methods were called on the mock?
2. How does it tell where these calls were made?
3. Is it easy to return values on specific method calls (think about
mocking BasicMath.add(first, second))?
4. How does it allow nested expressions to be checked
(e.g. mock.connection.cursor().execute("SELECT 1"))
These are just a few of the tasks that I imagine would become
uncomfortable in such an environment.
More information about the testing-in-python