[TIP] mock, nosetests, and third-party base classes
Gary Bernhardt
gary.bernhardt at gmail.com
Mon Jun 20 18:20:28 PDT 2011
On Mon, Jun 20, 2011 at 3:14 PM, Felix Yen <fyen at narrativescience.com> wrote:
> hi, i'm new here and hope my question wasn't answered earlier. (i did look
> at a bunch of archive threads ...) i derived a class from a third-party
> class; it looks a bit like this:
I feel compelled to show this because of how awful it is. It's the
first thing that came to mind:
# at the top level of your test module
mock.patch("pymongo.Connection", object)(lambda: __import__("mymodule"))()
# then import everything as normal
*ducks*
(It does work. Please don't ever do this.)
--
Gary
http://destroyallsoftware.com
More information about the testing-in-python
mailing list