Skip to content

Instantly share code, notes, and snippets.

@abadger
Created October 21, 2014 04:04
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 abadger/4a519b26b7480be20269 to your computer and use it in GitHub Desktop.
Save abadger/4a519b26b7480be20269 to your computer and use it in GitHub Desktop.
from mock import patch
import os.path
def test_func(path):
return os.path.exists(path)
def outer():
ope = os.path.exists
def inner(path):
return (ope(path), path)
with patch('os.path.exists', side_effect=inner):
print test_func('/etc/passwd')
outer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment