kgashok / pymox

Automatically exported from code.google.com/p/pymox
Apache License 2.0
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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