MCPcopy Index your code
hub / github.com/python/cpython / testBufferSetUp

Method testBufferSetUp

Lib/test/test_unittest/test_result.py:889–909  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

887 self.assertMultiLineEqual(message, expectedFullMessage)
888
889 def testBufferSetUp(self):
890 with captured_stdout() as stdout:
891 result = unittest.TestResult()
892 result.buffer = True
893
894 class Foo(unittest.TestCase):
895 def setUp(self):
896 print('set up')
897 1/0
898 def test_foo(self):
899 pass
900 suite = unittest.TestSuite([Foo('test_foo')])
901 suite(result)
902 expected_out = '\nStdout:\nset up\n'
903 self.assertEqual(stdout.getvalue(), expected_out)
904 self.assertEqual(len(result.errors), 1)
905 description = f'test_foo ({strclass(Foo)}.test_foo)'
906 test_case, formatted_exc = result.errors[0]
907 self.assertEqual(str(test_case), description)
908 self.assertIn('ZeroDivisionError: division by zero', formatted_exc)
909 self.assertIn(expected_out, formatted_exc)
910
911 def testBufferTearDown(self):
912 with captured_stdout() as stdout:

Callers

nothing calls this directly

Calls 7

captured_stdoutFunction · 0.90
strclassFunction · 0.90
strFunction · 0.85
assertInMethod · 0.80
FooClass · 0.70
assertEqualMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected