Comment 6 for bug 1256218

Revision history for this message
Marc Abramowitz (msabramo) wrote :

To make it easier to see the problem without TextTest, here's a command-line demonstration. Once there is a recorded mock and you try to replay it, then the error appears:

```
marca@marca-mac2:~/dev/bzr-repos/capturemock$ cat test_mutable_mapping.py
from capturemock import capturemock

@capturemock('moduletomock')
def test():
    from moduletomock import MyDict

    mutable_mapping = MyDict(animal='dog')

    print('mutable_mapping["animal"] = %r' % mutable_mapping["animal"])

test()
marca@marca-mac2:~/dev/bzr-repos/capturemock$ python test_mutable_mapping.py
mutable_mapping["animal"] = 'dog'
marca@marca-mac2:~/dev/bzr-repos/capturemock$ CAPTUREMOCK_MODE=1 python test_mutable_mapping.py
mutable_mapping["animal"] = 'dog'
marca@marca-mac2:~/dev/bzr-repos/capturemock$ python test_mutable_mapping.py
*** TypeError while trying to exec classDefStr = 'class MyDict(InstanceProxy, _abcoll.MutableMapping) : __metaclass__ = ProxyMetaClass'
Traceback (most recent call last):
  File "test_mutable_mapping.py", line 11, in <module>
    test()
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/__init__.py", line 210, in wrapped_func
    result = func(*funcargs, **funckw)
  File "test_mutable_mapping.py", line 5, in test
    from moduletomock import MyDict
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/pythonclient.py", line 103, in __getattr__
    self.captureMockTarget)
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/pythontraffic.py", line 535, in getAttribute
    return self.getAttributeFromReplay(traffic, proxyTarget, attrName, proxy, fullAttrName)
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/pythontraffic.py", line 552, in getAttributeFromReplay
    return proxy.captureMockCreateClassProxy(fullAttrName, newTarget, classDesc)
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/pythonclient.py", line 125, in captureMockCreateClassProxy
    classProxy = self.captureMockMakeClass(classDesc, proxyTarget)
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/pythonclient.py", line 122, in captureMockMakeClass
    return self.captureMockNameFinder.makeClass(classDesc, metaClassName)
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/pythonclient.py", line 48, in makeClass
    return self.defineClass(actualClassName, classDefStr)
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/pythonclient.py", line 17, in defineClass
    self.defineClassLocally(classDefStr)
  File "/Users/marca/dev/bzr-repos/capturemock/capturemock/pythonclient.py", line 61, in defineClassLocally
    exec(classDefStr, self)
  File "<string>", line 1, in <module>
TypeError: Error when calling the metaclass bases
    metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
```