I'd recommend using mock here instead of doing it this way. If your test experiences failure for any reason, the code you have at the end of this test won't execute, and so the "old_auth" won't be restored. mock.patch takes care of this for you.