Mock scope goes beyond current test
<p>I am mocking a module... here is my sample code</p>

<pre><code>def test_validate(self):
    """Test Base Retriever Dataframe"""

    sampleQuoteClass = self.sampleQuoteClass('ThisQuote')

    bRet._getAsOfData = MagicMock(return_value=sampleQuoteClass)

    dataAsDataFrame = bVal.validate(metaDataName='MyNewQuote')
    self.assertTrue(len(dataAsDataFrame) &gt; 0)
</code></pre>

<p>This works OK.</p>

<p>Problem is - bRet._getAsOfData is also mocked for the next tests, which incidentally resides in other test class.</p>

<p>This problem only occurs when all the tests are running together as a part of collection.</p>