From 5a84531d0e4f81fa4af078140a97b82aeca7c4c5 Mon Sep 17 00:00:00 2001 From: dglasser Date: Tue, 1 Jul 2008 01:43:55 +0000 Subject: Fix MoxTestBase to be usable with multiple-inheritance. MoxTestBase was redefining setUp() but it didn't use super() to call setUp recursively on the other parent classes defined in MRO. Patch by: Benoit Sigoure --- mox.py | 1 + mox_test.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/mox.py b/mox.py index a155aa0..70fba4f 100755 --- a/mox.py +++ b/mox.py @@ -1395,4 +1395,5 @@ class MoxTestBase(unittest.TestCase): __metaclass__ = MoxMetaTestBase def setUp(self): + super(MoxTestBase, self).setUp() self.mox = Mox() diff --git a/mox_test.py b/mox_test.py index df83c45..be35bae 100755 --- a/mox_test.py +++ b/mox_test.py @@ -1250,6 +1250,26 @@ class ResetTest(unittest.TestCase): self.assertEquals(0, len(mock_obj._expected_calls_queue)) +class MyTestCase(unittest.TestCase): + """Simulate the use of a fake wrapper around Python's unittest library.""" + + def setUp(self): + super(MyTestCase, self).setUp() + self.critical_variable = 42 + + +class MoxTestBaseMultipleInheritanceTest(mox.MoxTestBase, MyTestCase): + """Test that multiple inheritance can be used with MoxTestBase.""" + + def setUp(self): + super(MoxTestBaseMultipleInheritanceTest, self).setUp() + + def testMultipleInheritance(self): + """Should be able to access members created by all parent setUp().""" + self.assert_(isinstance(self.mox, mox.Mox)) + self.assertEquals(42, self.critical_variable) + + class TestClass: """This class is used only for testing the mock framework""" -- cgit v1.2.1