def tearDown(self): httpretty.disable() # disable afterwards, so that you will have no problems in code that uses that socket module httpretty.reset()