Skip to content

Instantly share code, notes, and snippets.

@devhero
Created April 20, 2018 12:37
Show Gist options
  • Save devhero/b83bbe97ba41a132db89d79659e06d23 to your computer and use it in GitHub Desktop.
Save devhero/b83bbe97ba41a132db89d79659e06d23 to your computer and use it in GitHub Desktop.
python mock patch
from unittest.mock import patch
class settings:
FIRST_PATCH = 1
SECOND_PATCH = 2
with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
assert settings.FIRST_PATCH == 'one'
assert settings.SECOND_PATCH == 'two'
assert settings.FIRST_PATCH == 1
assert settings.SECOND_PATCH == 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment