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

MockObject should provide a way to test methods like __str__ #29

Open
GoogleCodeExporter opened this issue Mar 19, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

class Foo:
    def __str__(self):
        print "Foo!"

class TestSuite(unittest.TestCase):
    def setUp(self):
        self.m = mox.Mox()
    def tearDown(self):
        self.m.UnsetStubs()

    def test_Foo_str(self):
        f = self.m.CreateMock(Foo)
        self.m.ReplayAll()
        res = str(f)  # res receives '<MockAnything instance at xx>'
        self.m.VerifyAll()


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

In most situations, MockObject.__str__ is useful but in some, it prevents from 
testing a class's __str__ method. Instead of receiving '<MockAnything...>' in 
the example above, there should be a way to make it receive "Foo!"

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

0.5.3

Debian GNU/Linux

Please provide any additional information below.

A short discussion was held about this subject on the mailing list[1] and it 
was suggested that some mechanism could disable MockObject's additional methods.

[1]:http://groups.google.com/group/mox-discuss/browse_thread/thread/72c214e943a3
ec16

Original issue reported on code.google.com by LeLu...@gmail.com on 27 Sep 2010 at 6:34

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