Here is some more details If I create my own mock object and pass that
in which follows the correct protocol:
class TestObject(object):
def read(*args, **kargs):
print "I am being Read"
return "readTest"
def readline(*args, **kargs):
print "Printline is being run"
return "TestRead"
urllib2.urlopen(mox.IsA(urllib2.Request)).AndRaise(urllib2.HTTPError
('
http://google.com',404, "test", {}, TestObject()))
The output is correct:
python mox-test.py
<addinfourl at 3081497388L whose fp = <socket._fileobject object at
0xb7d39b54>>
I am being Read
readTest
But When I pass in a mock objected created by mox:
f = m.CreateMockAnything()
f.read(mox.IgnoreArg()).AndReturn("Page not found")
urllib2.urlopen(mox.IsA(urllib2.Request)).AndRaise(urllib2.HTTPError
('
http://google.com',404, "test", {}, f))
This is my output:
python mox-test.py
<addinfourl at 3082164748L whose fp = <socket._fileobject object at
0xb7e68a3c>>
read() -> None # NO IDEA WHERE THIS IS COMING FROM
Traceback (most recent call last):
File "mox-test.py", line 40, in <module>
m.VerifyAll()
File "build/bdist.linux-i686/egg/mox.py", line 198, in VerifyAll
File "build/bdist.linux-i686/egg/mox.py", line 347, in _Verify
mox.ExpectedMethodCallsError: Verify: Expected methods never called:
0. read(<IgnoreArg>) -> 'Page not found'
1. read() -> None # ALSO NO IDEA WHERE THIS IS COMING FROM
>
smidd...@gmail.com