Issue 55 in pymox: String formatting error in StubOutWithMock method

7 views
Skip to first unread message

codesite...@google.com

unread,
Feb 26, 2013, 12:03:33 PM2/26/13
to mox-d...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 55 by aznm1k...@gmail.com: String formatting error in
StubOutWithMock method
http://code.google.com/p/pymox/issues/detail?id=55

What steps will reproduce the problem?
1. Try to call StubOutWithMock on an object with an attr_name that refers
to a tuple attribute. E.g.

moduleA.py:

MY_TUPLE_CONSTANT = (1,2,3)

testModuleA.py:

self.mox.StubOutWithMock(moduleA, 'MY_TUPLE_CONSTANT')

What is the expected output? What do you see instead?

I expect the function to pass normally, but there is a string formatting
error such as:

stub = self.CreateMockAnything(description='Stub for %s' %
attr_to_replace)
TypeError: not all arguments converted during string formatting

This is because attr_to_replace is a tuple object with more than one item
but the string formatting statement only expects one item in the tuple.

What version of the product are you using? On what operating system?

I'm using mox 0.5.3 on OS X 10.8

Please provide any additional information below.

I think the trivial patch here would be just wrap the attr_to_replace above
as tuple(attr_to_replace)


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

codesite...@google.com

unread,
Feb 26, 2013, 12:13:04 PM2/26/13
to mox-d...@googlegroups.com

Comment #1 on issue 55 by aznm1k...@gmail.com: String formatting error in
StubOutWithMock method
http://code.google.com/p/pymox/issues/detail?id=55

I've attached a patch (is this the best way to contribute?)

Attachments:
patch 479 bytes
Reply all
Reply to author
Forward
0 new messages