Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Lib/test/test_unittest/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,27 @@ def run(self, result):
self.assertIs(retval, resultOut)


# This test verifies that cooperative multiple inheritance works correctly
# when unittest.TestCase is combined with another class.
def test_init_support_cooperative_multiple_inheritance(self):
class Base:
def __init__(self):
super().__init__()
self.base_initialized = True

class Foo(unittest.TestCase, Base):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.testcase_initialized = True

def test_inheritance(self):
self.assertTrue(self.base_initialized)
self.assertTrue(self.testcase_initialized)

result = Foo('test_inheritance').run()
self.assertTrue(result.wasSuccessful())


def testShortDescriptionWithoutDocstring(self):
self.assertIsNone(self.shortDescription())

Expand Down
3 changes: 3 additions & 0 deletions Lib/unittest/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ def __init__(self, methodName='runTest'):
method when executed. Raises a ValueError if the instance does
not have a method with the specified name.
"""

super(TestCase, self).__init__()

self._testMethodName = methodName
self._outcome = None
self._testMethodDoc = 'No test'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added support :class:`unittest.TestCase` of multiple-inheritance
cooperative.
Loading