Skip to content

Instantly share code, notes, and snippets.

@obestwalter
Created March 8, 2017 12:16
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 obestwalter/2bae7adb5325984f801fc334ff1b8151 to your computer and use it in GitHub Desktop.
Save obestwalter/2bae7adb5325984f801fc334ff1b8151 to your computer and use it in GitHub Desktop.
Simple DIY plumbum local mock
from plumbum.machines import LocalMachine
def get_item_mock(*_, **__):
def i_am_the_mocked_function():
print("I am mocked")
return "mock value"
return i_am_the_mocked_function
LocalMachine.__getitem__ = get_item_mock
def test_something_with_mocked_local():
from plumbum import local
assert local["dontcare"]() == "mock value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment