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:<br><br>class Connection(pymongo.Connection):<br>
<div> def __init__(self, spam):<br> # translate spam ...<br> pymongo.Connection.__init__(self, host, port)<br><br>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:<br>
<br>1) assigning pymongo.Connection to a stub connection class, or<br>2) modifying sys.path and importing a fake pymongo package.<br><br>mock's documentation mentions that "<cite>nosetests</cite> does some manipulation of <cite>sys.modules</cite> (along with <cite>sys.path</cite>
manipulation)." so i think this "manipulation" is preventing me from patching my connection.<br><br>
</div>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.<br>
<br>
<br>Felix<br><br>