mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
Issue #22936: Allow showing local variables in unittest errors.
This commit is contained in:
parent
e37a1946c7
commit
f0c819acd0
9 changed files with 118 additions and 32 deletions
|
@ -158,7 +158,7 @@ class Test_TextTestRunner(unittest.TestCase):
|
|||
self.assertEqual(runner.warnings, None)
|
||||
self.assertTrue(runner.descriptions)
|
||||
self.assertEqual(runner.resultclass, unittest.TextTestResult)
|
||||
|
||||
self.assertFalse(runner.tb_locals)
|
||||
|
||||
def test_multiple_inheritance(self):
|
||||
class AResult(unittest.TestResult):
|
||||
|
@ -172,14 +172,13 @@ class Test_TextTestRunner(unittest.TestCase):
|
|||
# on arguments in its __init__ super call
|
||||
ATextResult(None, None, 1)
|
||||
|
||||
|
||||
def testBufferAndFailfast(self):
|
||||
class Test(unittest.TestCase):
|
||||
def testFoo(self):
|
||||
pass
|
||||
result = unittest.TestResult()
|
||||
runner = unittest.TextTestRunner(stream=io.StringIO(), failfast=True,
|
||||
buffer=True)
|
||||
buffer=True)
|
||||
# Use our result object
|
||||
runner._makeResult = lambda: result
|
||||
runner.run(Test('testFoo'))
|
||||
|
@ -187,6 +186,11 @@ class Test_TextTestRunner(unittest.TestCase):
|
|||
self.assertTrue(result.failfast)
|
||||
self.assertTrue(result.buffer)
|
||||
|
||||
def test_locals(self):
|
||||
runner = unittest.TextTestRunner(stream=io.StringIO(), tb_locals=True)
|
||||
result = runner.run(unittest.TestSuite())
|
||||
self.assertEqual(True, result.tb_locals)
|
||||
|
||||
def testRunnerRegistersResult(self):
|
||||
class Test(unittest.TestCase):
|
||||
def testFoo(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue