Skip to content

Instantly share code, notes, and snippets.

@pgiraud
Created June 29, 2017 07:17
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 pgiraud/6966f2f456e56eb711d694adfd0decbf to your computer and use it in GitHub Desktop.
Save pgiraud/6966f2f456e56eb711d694adfd0decbf to your computer and use it in GitHub Desktop.
def test_mock_open(mocker):
with mocker.patch('builtins.open', mocker.mock_open(read_data='foo')):
with open(__file__) as f:
assert f.read() == 'foo'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment