Back to index

python3.2  3.2.2
Public Member Functions
unittest.test.test_result.Test_TestResult Class Reference

List of all members.

Public Member Functions

def test_init
def test_stop
def test_startTest
def test_stopTest
def test_startTestRun_stopTestRun
def test_addSuccess
def test_addFailure
def test_addError
def testGetDescriptionWithoutDocstring
def testGetDescriptionWithOneLineDocstring
def testGetDescriptionWithMultiLineDocstring
def testStackFrameTrimming
def testFailFast
def testFailFastSetByRunner

Detailed Description

Definition at line 11 of file test_result.py.


Member Function Documentation

Definition at line 203 of file test_result.py.

00203 
00204     def test_addError(self):
00205         class Foo(unittest.TestCase):
00206             def test_1(self):
00207                 pass
00208 
00209         test = Foo('test_1')
00210         try:
00211             raise TypeError()
00212         except:
00213             exc_info_tuple = sys.exc_info()
00214 
00215         result = unittest.TestResult()
00216 
00217         result.startTest(test)
00218         result.addError(test, exc_info_tuple)
00219         result.stopTest(test)
00220 
00221         self.assertFalse(result.wasSuccessful())
00222         self.assertEqual(len(result.errors), 1)
00223         self.assertEqual(len(result.failures), 0)
00224         self.assertEqual(result.testsRun, 1)
00225         self.assertEqual(result.shouldStop, False)
00226 
00227         test_case, formatted_exc = result.errors[0]
00228         self.assertTrue(test_case is test)
00229         self.assertIsInstance(formatted_exc, str)

Definition at line 155 of file test_result.py.

00155 
00156     def test_addFailure(self):
00157         class Foo(unittest.TestCase):
00158             def test_1(self):
00159                 pass
00160 
00161         test = Foo('test_1')
00162         try:
00163             test.fail("foo")
00164         except:
00165             exc_info_tuple = sys.exc_info()
00166 
00167         result = unittest.TestResult()
00168 
00169         result.startTest(test)
00170         result.addFailure(test, exc_info_tuple)
00171         result.stopTest(test)
00172 
00173         self.assertFalse(result.wasSuccessful())
00174         self.assertEqual(len(result.errors), 0)
00175         self.assertEqual(len(result.failures), 1)
00176         self.assertEqual(result.testsRun, 1)
00177         self.assertEqual(result.shouldStop, False)
00178 
00179         test_case, formatted_exc = result.failures[0]
00180         self.assertTrue(test_case is test)
00181         self.assertIsInstance(formatted_exc, str)

Definition at line 116 of file test_result.py.

00116 
00117     def test_addSuccess(self):
00118         class Foo(unittest.TestCase):
00119             def test_1(self):
00120                 pass
00121 
00122         test = Foo('test_1')
00123 
00124         result = unittest.TestResult()
00125 
00126         result.startTest(test)
00127         result.addSuccess(test)
00128         result.stopTest(test)
00129 
00130         self.assertTrue(result.wasSuccessful())
00131         self.assertEqual(len(result.errors), 0)
00132         self.assertEqual(len(result.failures), 0)
00133         self.assertEqual(result.testsRun, 1)
00134         self.assertEqual(result.shouldStop, False)

Definition at line 21 of file test_result.py.

00021 
00022     def test_init(self):
00023         result = unittest.TestResult()
00024 
00025         self.assertTrue(result.wasSuccessful())
00026         self.assertEqual(len(result.errors), 0)
00027         self.assertEqual(len(result.failures), 0)
00028         self.assertEqual(result.testsRun, 0)
00029         self.assertEqual(result.shouldStop, False)
00030         self.assertIsNone(result._stdout_buffer)
00031         self.assertIsNone(result._stderr_buffer)

Here is the call graph for this function:

Definition at line 44 of file test_result.py.

00044 
00045     def test_startTest(self):
00046         class Foo(unittest.TestCase):
00047             def test_1(self):
00048                 pass
00049 
00050         test = Foo('test_1')
00051 
00052         result = unittest.TestResult()
00053 
00054         result.startTest(test)
00055 
00056         self.assertTrue(result.wasSuccessful())
00057         self.assertEqual(len(result.errors), 0)
00058         self.assertEqual(len(result.failures), 0)
00059         self.assertEqual(result.testsRun, 1)
00060         self.assertEqual(result.shouldStop, False)
00061 
00062         result.stopTest(test)

Definition at line 92 of file test_result.py.

00092 
00093     def test_startTestRun_stopTestRun(self):
00094         result = unittest.TestResult()
00095         result.startTestRun()
00096         result.stopTestRun()

Definition at line 35 of file test_result.py.

00035 
00036     def test_stop(self):
00037         result = unittest.TestResult()
00038 
00039         result.stop()
00040 
00041         self.assertEqual(result.shouldStop, True)

Here is the call graph for this function:

Definition at line 65 of file test_result.py.

00065 
00066     def test_stopTest(self):
00067         class Foo(unittest.TestCase):
00068             def test_1(self):
00069                 pass
00070 
00071         test = Foo('test_1')
00072 
00073         result = unittest.TestResult()
00074 
00075         result.startTest(test)
00076 
00077         self.assertTrue(result.wasSuccessful())
00078         self.assertEqual(len(result.errors), 0)
00079         self.assertEqual(len(result.failures), 0)
00080         self.assertEqual(result.testsRun, 1)
00081         self.assertEqual(result.shouldStop, False)
00082 
00083         result.stopTest(test)
00084 
00085         # Same tests as above; make sure nothing has changed
00086         self.assertTrue(result.wasSuccessful())
00087         self.assertEqual(len(result.errors), 0)
00088         self.assertEqual(len(result.failures), 0)
00089         self.assertEqual(result.testsRun, 1)
00090         self.assertEqual(result.shouldStop, False)

Definition at line 272 of file test_result.py.

00272 
00273     def testFailFast(self):
00274         result = unittest.TestResult()
00275         result._exc_info_to_string = lambda *_: ''
00276         result.failfast = True
00277         result.addError(None, None)
00278         self.assertTrue(result.shouldStop)
00279 
00280         result = unittest.TestResult()
00281         result._exc_info_to_string = lambda *_: ''
00282         result.failfast = True
00283         result.addFailure(None, None)
00284         self.assertTrue(result.shouldStop)
00285 
00286         result = unittest.TestResult()
00287         result._exc_info_to_string = lambda *_: ''
00288         result.failfast = True
00289         result.addUnexpectedSuccess(None)
00290         self.assertTrue(result.shouldStop)

Here is the call graph for this function:

Definition at line 291 of file test_result.py.

00291 
00292     def testFailFastSetByRunner(self):
00293         runner = unittest.TextTestRunner(stream=io.StringIO(), failfast=True)
00294         def test(result):
00295             self.assertTrue(result.failfast)
00296         result = runner.run(test)
00297 

Here is the call graph for this function:

Tests getDescription() for a method with a longer docstring.
The second line of the docstring.

Definition at line 250 of file test_result.py.

00250 
00251     def testGetDescriptionWithMultiLineDocstring(self):
00252         """Tests getDescription() for a method with a longer docstring.
00253         The second line of the docstring.
00254         """
00255         result = unittest.TextTestResult(None, True, 1)
00256         self.assertEqual(
00257                 result.getDescription(self),
00258                ('testGetDescriptionWithMultiLineDocstring '
00259                 '(' + __name__ + '.Test_TestResult)\n'
00260                 'Tests getDescription() for a method with a longer '
00261                 'docstring.'))

Here is the call graph for this function:

Tests getDescription() for a method with a docstring.

Definition at line 239 of file test_result.py.

00239 
00240     def testGetDescriptionWithOneLineDocstring(self):
00241         """Tests getDescription() for a method with a docstring."""
00242         result = unittest.TextTestResult(None, True, 1)
00243         self.assertEqual(
00244                 result.getDescription(self),
00245                ('testGetDescriptionWithOneLineDocstring '
00246                 '(' + __name__ + '.Test_TestResult)\n'
00247                 'Tests getDescription() for a method with a docstring.'))

Here is the call graph for this function:

Definition at line 230 of file test_result.py.

00230 
00231     def testGetDescriptionWithoutDocstring(self):
00232         result = unittest.TextTestResult(None, True, 1)
00233         self.assertEqual(
00234                 result.getDescription(self),
00235                 'testGetDescriptionWithoutDocstring (' + __name__ +
00236                 '.Test_TestResult)')

Here is the call graph for this function:

Definition at line 262 of file test_result.py.

00262 
00263     def testStackFrameTrimming(self):
00264         class Frame(object):
00265             class tb_frame(object):
00266                 f_globals = {}
00267         result = unittest.TestResult()
00268         self.assertFalse(result._is_relevant_tb_level(Frame))
00269 
00270         Frame.tb_frame.f_globals['__unittest'] = True
00271         self.assertTrue(result._is_relevant_tb_level(Frame))

Here is the call graph for this function:


The documentation for this class was generated from the following file: