Skip to content

Instantly share code, notes, and snippets.

@otherwiseguy
Last active May 17, 2017 14:51
Show Gist options
  • Save otherwiseguy/4f1738b8e6fc3a1c6f6f6ff0238a5a8a to your computer and use it in GitHub Desktop.
Save otherwiseguy/4f1738b8e6fc3a1c6f6f6ff0238a5a8a to your computer and use it in GitHub Desktop.
def add(x, y):
val = 0
for i in range(x + y):
val += 1
return val
import mock
import unittest
from adder import add
class TestAdd(unittest.TestCase):
def test_add_wrong(self):
x, y = 1, 3
with mock.patch.object(add, 'range') as mock_range:
add.add(x, y)
mock_range.assert_called_once_with(x + y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment