Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String formatting error in StubOutWithMock method #55

Open
GoogleCodeExporter opened this issue Mar 19, 2015 · 1 comment
Open

String formatting error in StubOutWithMock method #55

GoogleCodeExporter opened this issue Mar 19, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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)

Original issue reported on code.google.com by aznm1k...@gmail.com on 26 Feb 2013 at 5:03

@GoogleCodeExporter
Copy link
Author

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

Original comment by aznm1k...@gmail.com on 26 Feb 2013 at 5:12

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant