Back to index

python3.2  3.2.2
Classes | Public Member Functions | Public Attributes
unittest.test.test_program.Test_TestProgram Class Reference

List of all members.

Classes

class  FooBar
class  FooBarLoader

Public Member Functions

def test_discovery_from_dotted_path
def testNoExit
def test_NonExit
def test_Exit
def test_ExitAsDefault

Public Attributes

 wasRun
 test

Detailed Description

Definition at line 8 of file test_program.py.


Member Function Documentation

Definition at line 10 of file test_program.py.

00010 
00011     def test_discovery_from_dotted_path(self):
00012         loader = unittest.TestLoader()
00013 
00014         tests = [self]
00015         expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__))
00016 
00017         self.wasRun = False
00018         def _find_tests(start_dir, pattern):
00019             self.wasRun = True
00020             self.assertEqual(start_dir, expectedPath)
00021             return tests
00022         loader._find_tests = _find_tests
00023         suite = loader.discover('unittest.test')
00024         self.assertTrue(self.wasRun)
00025         self.assertEqual(suite._tests, tests)

Definition at line 76 of file test_program.py.

00076 
00077     def test_Exit(self):
00078         self.assertRaises(
00079             SystemExit,
00080             unittest.main,
00081             argv=["foobar"],
00082             testRunner=unittest.TextTestRunner(stream=io.StringIO()),
00083             exit=True,
00084             testLoader=self.FooBarLoader())
00085 

Here is the call graph for this function:

Definition at line 86 of file test_program.py.

00086 
00087     def test_ExitAsDefault(self):
00088         self.assertRaises(
00089             SystemExit,
00090             unittest.main,
00091             argv=["foobar"],
00092             testRunner=unittest.TextTestRunner(stream=io.StringIO()),
00093             testLoader=self.FooBarLoader())
00094 

Here is the call graph for this function:

Definition at line 68 of file test_program.py.

00068 
00069     def test_NonExit(self):
00070         program = unittest.main(exit=False,
00071                                 argv=["foobar"],
00072                                 testRunner=unittest.TextTestRunner(stream=io.StringIO()),
00073                                 testLoader=self.FooBarLoader())
00074         self.assertTrue(hasattr(program, 'result'))
00075 

Here is the call graph for this function:

Definition at line 27 of file test_program.py.

00027 
00028     def testNoExit(self):
00029         result = object()
00030         test = object()
00031 
00032         class FakeRunner(object):
00033             def run(self, test):
00034                 self.test = test
00035                 return result
00036 
00037         runner = FakeRunner()
00038 
00039         oldParseArgs = unittest.TestProgram.parseArgs
00040         def restoreParseArgs():
00041             unittest.TestProgram.parseArgs = oldParseArgs
00042         unittest.TestProgram.parseArgs = lambda *args: None
00043         self.addCleanup(restoreParseArgs)
00044 
00045         def removeTest():
00046             del unittest.TestProgram.test
00047         unittest.TestProgram.test = test
00048         self.addCleanup(removeTest)
00049 
00050         program = unittest.TestProgram(testRunner=runner, exit=False, verbosity=2)
00051 
00052         self.assertEqual(program.result, result)
00053         self.assertEqual(runner.test, test)
00054         self.assertEqual(program.verbosity, 2)

Here is the call graph for this function:


Member Data Documentation

Definition at line 33 of file test_program.py.

Definition at line 16 of file test_program.py.


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