Ejemplo n.º 1
0
 def setUp(self):
     CONSTANTS.errStream = io.StringIO()
     self.runner = BoostRunner()
Ejemplo n.º 2
0
class BoostRunner_Test(unittest.TestCase):
    '''
    For the tests that use Boost_Test, I'm not sure if
    they will work on Windows because the file is a linux
    compiled file. But the changes necessary aren't that
    difficult to make. If you come up with a better way
    of implementing the test, such that its easier to
    switch binaries, or you want me to, please let me
    know.
    
    Boost_Test is just a compiled version of the source
    code found here:
    http://www.boost.org/doc/libs/1_42_0/libs/test/doc/html/utf/user-guide/runtime-config/run-by-name.html
    
    @warning The tests that use Boost_Test will fail if access to
        Boost_Test is denied by the OS. This happens when TestParser has
        been installed in a virtualenv, for instance.
    
    @date Mar 6, 2010
    @author: Matthew A. Todd
    '''


    def setUp(self):
        CONSTANTS.errStream = io.StringIO()
        self.runner = BoostRunner()

    def tearDown(self):
        CONSTANTS.resetErrStream()
        del self.runner

    def testRunAll(self):
        '''
        test runAll() with real input
        '''
        self.runner.runner = computeDataFilepath("./sample/Boost_Test", __file__)
        stdout = self.runner.runAll()
        self.assertNotEqual(stdout, None)

    def testRunTest_echo(self):
        '''
        test runTest() using echo
        '''
        self.runner.runner = "echo"
        
        input = "echo test output"
        output = "%s --log_level=all --run_test=%s\n" % (BoostRunner.LOG_FORMAT, input)
        stdout = self.runner.runTest([input])
        self.assertEqual(stdout.decode("utf-8"), output)
        
        input1 = "test1"
        input2 = "test2"
        output = "%s --log_level=all --run_test=%s,%s\n" % (BoostRunner.LOG_FORMAT, input1, input2)
        stdout = self.runner.runTest([input1, input2])
        self.assertEqual(stdout.decode("utf-8"), output)
        
    def testRunTest(self):
        '''
        test runTest() with real input
        '''
        self.runner.runner = computeDataFilepath("./sample/Boost_Test", __file__)
        stdout = self.runner.runTest(["testA", "testB"])
        self.assertNotEqual(stdout, None)
        
    def testRunSuite(self):
        '''
        test runSuite() with real input
        '''
        self.runner.runner = computeDataFilepath("./sample/Boost_Test", __file__)
        stdout = self.runner.runSuite([])
        self.assertNotEqual(stdout, None)
        
    def test_computeCmd(self):
        '''
        Test that the command returned is correct
        '''
        self.runner.runner = "<runner>"
        input = ["input"]
        output = self.runner.runner + [BoostRunner.LOG_FORMAT, "--log_level=all"] + input
        self.assertEqual(self.runner.computeCmd(input), output)