Skip to content

Instantly share code, notes, and snippets.

@codeguru42
Last active February 22, 2018 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeguru42/9760d38d4f4ff891d045b53c1a0a64d9 to your computer and use it in GitHub Desktop.
Save codeguru42/9760d38d4f4ff891d045b53c1a0a64d9 to your computer and use it in GitHub Desktop.
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)
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