summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordglasser <dglasser@b1010a0a-674b-0410-b734-77272b80c875>2008-07-01 01:43:55 +0000
committerdglasser <dglasser@b1010a0a-674b-0410-b734-77272b80c875>2008-07-01 01:43:55 +0000
commit1c502e37d1243faa8678f7c35943fd89ab2102f9 (patch)
treefd45b7575ba3caa42a345752e2c5881e123c84cb
parent7f2c742a739a4a81009d0be82d29bbde0cecd222 (diff)
downloadmox-1c502e37d1243faa8678f7c35943fd89ab2102f9.tar.gz
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 <tsuna@lrde.epita.fr> git-svn-id: http://pymox.googlecode.com/svn/trunk@17 b1010a0a-674b-0410-b734-77272b80c875
-rwxr-xr-xmox.py1
-rwxr-xr-xmox_test.py20
2 files changed, 21 insertions, 0 deletions
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"""