Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Created December 11, 2013 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdwardIII/da53fc07fd8ec395c221 to your computer and use it in GitHub Desktop.
Save EdwardIII/da53fc07fd8ec395c221 to your computer and use it in GitHub Desktop.
class SomeTest(TestCase):
@patch('requests.post', requests_mock)
def testSomething:
requests_mock.return_value = { 'status_code': 200, 'text': '<some xml />' }
pretend = PretendObj() // a pretend object that uses requests.post behind the scenes
# I want to use the patched requests_mock here
self.assertEqual('<mocked xml />', pretend.getResult());
# But then I want to be able to temporarily call an unmocked, real request here
self.assertEqual('<not mocked xml xml />', pretend.getResult());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment