Esempio n. 1
0
    def run(self):
        '''
        Finds all the tests modules in test/, and runs them.
        '''
        sys.path.insert(0, 'src/')

        sys.path.insert(0, 'test/src/')

        from common.xmlrunner import XMLTestRunner
        from test_pylstar import suite_global

        # We retrieve the current test suite
        currentTestSuite = suite_global.getSuite()

        if self.reportfile is None or len(self.reportfile) == 0:
            runner = unittest.TextTestRunner()
            runner.run(currentTestSuite)
        else:
            # We execute the test suite
            File = open(self.reportfile, 'w')
            File.write('<?xml version="1.0" encoding="utf-8"?>\n')
            reporter = XMLTestRunner(File)
            reporter.run(currentTestSuite)
            File.close()

            self.cleanFile(self.reportfile)
Esempio n. 2
0
    def run(self):
        '''
        Finds all the tests modules in test/, and runs them.
        '''
        sys.path.insert(0, 'src/')

        #insert in the path the directory where _libNeedleman.pyd is
        if os.name == 'nt':
            sys.path.insert(0, 'lib/libNeedleman/')

        try:
            # Verify that libNeedleman is in the path
            from netzob import _libNeedleman
        except:
            # Else, assume the path is gotten from the 'python setup.py build' command
            arch = os.uname()[-1]
            python_version = sys.version[:3]
            build_lib_path = "build/lib.linux-" + arch + "-" + python_version
            sys.path.append(build_lib_path)

        sys.path.insert(0, 'test/src/')

        from common.xmlrunner import XMLTestRunner
        from test_netzob import suite_global
        #import netzob.NetzobGui as NetzobGui

        # We retrieve the current test suite
        currentTestSuite = suite_global.getSuite()

        # We execute the test suite
        File = open(self.reportfile, "w")
        reporter = XMLTestRunner(File)
        reporter.run(currentTestSuite)
        File.close()
Esempio n. 3
0
    def run(self):
        '''
        Finds all the tests modules in test/, and runs them.
        '''
        sys.path.insert(0, 'src/')

        #insert in the path the directory where _libNeedleman.pyd is
        if os.name == 'nt':
            sys.path.insert(0, 'lib/libNeedleman/')

        try:
            # Verify that libNeedleman is in the path
            from netzob import _libNeedleman
        except:
            # Else, assume the path is gotten from the 'python setup.py build' command
            arch = os.uname()[-1]
            python_version = sys.version[:3]
            build_lib_path = "build/lib.linux-" + arch + "-" + python_version
            sys.path.append(build_lib_path)

        sys.path.insert(0, 'test/src/')

        from common.xmlrunner import XMLTestRunner
        from test_netzob import suite_global
        #import netzob.NetzobGui as NetzobGui

        # We retrieve the current test suite
        currentTestSuite = suite_global.getSuite()

        testResults = None

        if self.reportfile is None or len(self.reportfile) == 0:
            runner = unittest.TextTestRunner(verbosity=1)
            testResults = runner.run(currentTestSuite)
        else:
            # We execute the test suite
            with open(self.reportfile, 'w') as fd:
                fd.write('<?xml version="1.0" encoding="utf-8"?>\n')
                reporter = XMLTestRunner(fd)
                testResults = reporter.run(currentTestSuite)

            self.cleanFile(self.reportfile)

        if testResults is None:
            sys.exit(False)
        else:
            sys.exit(bool(testResults.failures))
Esempio n. 4
0
        globalSuite.addTests(unittest.TestLoader().loadTestsFromModule(module))

    # Add suites
    for module in modulesOfSuites:
        globalSuite.addTests(module.getSuite())

    return globalSuite


if __name__ == "__main__":
    # Output is given through argument.
    # If no argument: output to stdout
    outputStdout = True

    if (len(sys.argv) == 2):
        outputStdout = False
        reportFile = sys.argv[1]

    # We retrieve the current test suite
    currentTestSuite = getSuite()

    # We execute the test suite
    if outputStdout:
        runner = unittest.TextTestRunner()
        testResult = runner.run(currentTestSuite)
    else:
        File = open(reportFile, "w")
        reporter = XMLTestRunner(File)
        reporter.run(currentTestSuite)
        File.close()