From da2bf9f66d0c95b988c5d87646d168f65499b316 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 12 Oct 2018 07:35:55 -0300 Subject: bpo-34900: Make TestCase.debug() work with subtests (GH-9707) --- Lib/unittest/test/test_case.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Lib/unittest/test/test_case.py') diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py index baabddd06f..687fe5b65f 100644 --- a/Lib/unittest/test/test_case.py +++ b/Lib/unittest/test/test_case.py @@ -425,6 +425,20 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing): expected = ['a1', 'a2', 'b1'] self.assertEqual(events, expected) + def test_subtests_debug(self): + # Test debug() with a test that uses subTest() (bpo-34900) + events = [] + + class Foo(unittest.TestCase): + def test_a(self): + events.append('test case') + with self.subTest(): + events.append('subtest 1') + + Foo('test_a').debug() + + self.assertEqual(events, ['test case', 'subtest 1']) + # "This class attribute gives the exception raised by the test() method. # If a test framework needs to use a specialized exception, possibly to # carry additional information, it must subclass this exception in -- cgit v1.2.1