Last active
February 22, 2018 16:36
-
-
Save codeguru42/9760d38d4f4ff891d045b53c1a0a64d9 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
F | |
====================================================================== | |
FAIL: test_foo (__main__.FooTest) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/home/l/.IntelliJIdea2017.3/config/scratches/scratch.py", line 11, in test_foo | |
self.assertEqual(expected, actual) | |
AssertionError: 'foobar' != <MagicMock name='mock.foo()' id='140619506578448'> | |
---------------------------------------------------------------------- | |
Ran 1 test in 0.001s | |
FAILED (failures=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
from mock import MagicMock | |
from unittest import TestCase, main | |
class FooTest(TestCase): | |
def test_foo(self): | |
expected = 'foobar' | |
bar = MagicMock() | |
bar.func.return_value = expected | |
actual = bar.foo() | |
self.assertEqual(expected, actual) | |
def foo(bar): | |
return bar.func() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment