[TIP] weirdity with identity of Mock

Chris Withers chris at simplistix.co.uk
Wed Jan 25 11:56:27 PST 2012


So, this won't come as much surprise:

 >> class MyClass(object): pass
...
 >>> obj1 = MyClass()
 >>> obj2 = MyClass()
 >>> obj1 == obj2
False
 >>> type(obj1) is type(obj2)
True

...but this certainly surprised me:

 >>> from mock import Mock
 >>> obj1 = Mock()
 >>> obj2 = Mock()
 >>> type(obj1) is type(obj2)
False

Wuh?

 >>> Mock is Mock
True

Mmmmkay...

*backs away slightly scared*

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
             - http://www.simplistix.co.uk



More information about the testing-in-python mailing list