[TIP] mock, nosetests, and third-party base classes
kumar.mcmillan at gmail.com
Mon Jun 20 16:28:58 PDT 2011
On Mon, Jun 20, 2011 at 5:14 PM, Felix Yen <fyen at narrativescience.com> wrote:
> using mock 0.7.2, i wrote a unit test that validates the host and port
> values passed to the base class constructor. however, this test fails when
> nosetests runs it. without nose (1.0.0), i can get the test to succeed in
> two ways:
> 1) assigning pymongo.Connection to a stub connection class, or
> 2) modifying sys.path and importing a fake pymongo package.
Hmm, weird. Could you post the test that fails in Nose?
> mock's documentation mentions that "nosetests does some manipulation of
> sys.modules (along with sys.path manipulation)." so i think this
> "manipulation" is preventing me from patching my connection.
> has anyone seen this problem before? more generally/importantly, what's a
> good way of mocking third-party base classes?? i'm using Python 2.7 and mock
> usage is optional (though it's hard to imagine *not* using it), but nose
> usage is mandatory.
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
More information about the testing-in-python