Why doesn't the "wraps" keyword work consistently for MagicMock objects? Normal methods are passed through to the wrapped object, but not "special" methods. In the test below, the first assertion passes, the second fails.
import mock
import unittest
class Foo(object):
def bar(self):
return 1
def __len__(self):
return 3
class TestWrap(unittest.TestCase):
def test(self):
foo = Foo()
c = mock.MagicMock(wraps=foo)
assert c.bar() == 1 # Passes
assert len(c) == 3 # Fails
I cannot find anything in the docs that suggests this. Am I missing something?