instead of creating mocks like this  which do not unset themselves after the function scope it is better to use  mock patch decorators on the test method  mock patch object ipt driver cls instance info mock patch object ipt driver cls remove filters for instance  def test unfilter instance self  remove mock  instance info mock  