Last active
January 18, 2018 16:03
-
-
Save padawin/595736286a49fed259de310fb39401c1 to your computer and use it in GitHub Desktop.
This file contains 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
def func1(): | |
return "1" |
This file contains 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
def func2(): | |
return "2" |
This file contains 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
pytest==3.3.0 |
This file contains 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.mock import patch | |
import toTest | |
import module1 | |
import module2 | |
@patch.object(module1, 'func1') | |
@patch.object(module2, 'func2') | |
def test_myfuncs(mock2, mock1): | |
mock1.return_value = "Return mock 1" | |
mock2.return_value = "Return mock 2" | |
res = toTest.functionToTest() | |
assert res == ("Return mock 1", "Return mock 2") |
This file contains 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
import module1 | |
from module2 import func2 | |
def functionToTest(): | |
return module1.func1(), func2() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment