Created
September 12, 2017 20:40
-
-
Save orsenthil/ae7c9840ca2b4ee7331f2f7fb39eaae1 to your computer and use it in GitHub Desktop.
Using Mock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Production: | |
def call_one(self, arg1, arg2): | |
return arg1 + arg2 | |
def call_two(self, arg1, arg2, arg3): | |
return self.call_one(str(arg1), str(arg2) + str(arg3)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest import mock | |
import unittest | |
from production import Production | |
class TestModule(unittest.TestCase): | |
@mock.patch("production.Production.call_one") | |
def test_case(self, mock_call_one): | |
expected = "something" | |
mock_call_one.return_value = expected | |
prod = Production() | |
response = prod.call_two(1, 2, 3) | |
self.assertEqual(response, expected) | |
Author
orsenthil
commented
Sep 12, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment