Skip to content

Instantly share code, notes, and snippets.

@edgabaldi
Last active August 29, 2015 14:07
Show Gist options
  • Save edgabaldi/f33354497f978918f5b2 to your computer and use it in GitHub Desktop.
Save edgabaldi/f33354497f978918f5b2 to your computer and use it in GitHub Desktop.
patch example
import random
from unittest import TestCase
from mock import patch
def get_age():
return random.randint(15, 99)
class AgeTest(TestCase):
@patch('patch_example.random.randint')
def test_gen_age(self, _func):
get_age()
_func.assert_called_once_with(15, 99)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment