def run(self, args):
     if not self.args(args):
         return False
     self.handler = StandardResultHandler(self._pageName, self._host,
                                          self._port)
     self.establishCommonTopLevelOptions(self.options, self._pythonPath)
     self.pushRunOptionsToTest()
     self.establishConnection(self.makeHttpRequest(), self._host,
                              self._port)
     self.validateConnection()
     if not self.options.pythonPath:
         classpathItems = self._processClasspathDocument()
         if classpathItems:
             cpMsg = "Classpath received from server: " + classpathItems
             if self.options.verbose:
                 conMsg.rmsg(cpMsg)
             else:
                 conMsg.tmsg(cpMsg)
         self._pythonPath, renamesFileName = self.extractPythonPath(
             classpathItems, self.options)
         self._renamesFileName = firstNonNone(renamesFileName,
                                              self._renamesFileName)
         self.pushRunOptionsToTest()
         self.establishTestLevelOptions(self.options, self._pythonPath)
     FG.appConfigInterface("beforeRunExecution")
     self.executor = FitNesseTestExecutor(self.fixtureListener,
                                          self.options)
     result = self.executor.process(self._renamesFileName)
     FG.appConfigInterface("afterRunExecution", result)
     self._finalCount()
     self.closeConnection()
     self.handler.cleanUp()
     self._statsHandler.endOfAllTests()
     self._statsHandler.writeStats()
     return True
コード例 #2
0
 def run(self, args):
     if not self.args(args):
         return False
     self.handler = StandardResultHandler(self._pageName,
                                          self._host, self._port)
     self.establishCommonTopLevelOptions(self.options, self._pythonPath)
     self.pushRunOptionsToTest()
     self.establishConnection(self.makeHttpRequest(),
                              self._host, self._port)
     self.validateConnection()
     if not self.options.pythonPath:
         classpathItems = self._processClasspathDocument()
         if classpathItems:
             cpMsg = "Classpath received from server: " + classpathItems
             if self.options.verbose:
                 conMsg.rmsg(cpMsg)
             else:
                 conMsg.tmsg(cpMsg)
         self._pythonPath, renamesFileName = self.extractPythonPath(
             classpathItems, self.options)
         self._renamesFileName = firstNonNone(renamesFileName,
                                              self._renamesFileName)
         self.pushRunOptionsToTest()
         self.establishTestLevelOptions(self.options, self._pythonPath)
     FG.appConfigInterface("beforeRunExecution")
     self.executor = FitNesseTestExecutor(self.fixtureListener,
                                          self.options)
     result = self.executor.process(self._renamesFileName) 
     FG.appConfigInterface("afterRunExecution", result)
     self._finalCount()
     self.closeConnection()
     self.handler.cleanUp()
     self._statsHandler.endOfAllTests()
     self._statsHandler.writeStats()
     return True
コード例 #3
0
 def run(self):
     FG.RunOptions = self.options
     self.pushRunOptionsToTest()
     if not self._runObj.verify():
         return -1
     FG.appConfigInterface("beforeRunExecution")
     self._runObj.run()
     finalTotals = conTotal.finalTotal()
     FG.appConfigInterface("afterRunExecution", finalTotals)
     stats.writeXMLFile()
     return finalTotals.numErrors()
コード例 #4
0
 def run(self):
     for item, opts in self.executionList:
         FG.appConfigInterface("individualTestOptions", opts)
         self.pushRunOptionsToTest()
         result = self.establishTestLevelOptions(opts, [])
         if result is True:
             item.run()
         else:
             conMsg.err(result)
         FG.Options = FG.RunOptions
     return
コード例 #5
0
 def run(self):
     for item, opts in self.executionList:
         FG.appConfigInterface("individualTestOptions", opts)
         self.pushRunOptionsToTest()
         result = self.establishTestLevelOptions(opts, [])
         if result is True:
             item.run()
         else:
             conMsg.err(result)
         FG.Options = FG.RunOptions
     return
コード例 #6
0
 def run(self):
     FG.RunOptions = self.options
     self.pushRunOptionsToTest()
     if not self._runObj.verify():
         return -1
     FG.appConfigInterface("beforeRunExecution")
     self._runObj.run()
     finalTotals = conTotal.finalTotal()
     FG.appConfigInterface("afterRunExecution", finalTotals)
     stats.writeXMLFile()
     return finalTotals.numErrors()
 def run(self, argv):
     result = self.args(argv)
     if not result:
         return result
     self.establishCommonTopLevelOptions(self.options,
                                         self._addToPythonPath)
     self.establishConnection(self._makeHttpRequest(), self.host, self.port)
     self.validateConnection()
     FG.appConfigInterface("beforeRunExecution")
     self.executor = FitNesseTestExecutor(TablePrintingFixtureListener(),
                                          self.options)
     self.counts = self.executor.process(self._renameFileName)
     FG.appConfigInterface("afterRunExecution", self.counts)
     self.closeConnection()
     self.exit()
     return self.exitCode()
コード例 #8
0
ファイル: FitException.py プロジェクト: radiocutfm/pyfit
    def getMeaningfulMessage(self):
        __pychecker__ = "no-classattr" # self.args
        args = self.args
        if len(args) == 0:
            args = ("zeroLengthArgs",)
        #
        numParms, isExc, doTrace, template = self.templates.get(args[0],
                                                (None, None, None, None))
        if numParms is None:
            isExc, doTrace = EXC, TRACE
            msg = ("Unknown Message Key. Application Configuration Exit"
                   " did not override it.")

        exitResult = FitGlobal.appConfigInterface("mapErrorMessage", args,
                                              isExc, doTrace)
        #
        if exitResult is None:
            return self.extractEnglishMessage(args)

        if isinstance(exitResult, StringTypes):
            return isExc, doTrace, exitResult

        if exitResult[0] is None:
            isExc, doTrace, msg = self.extractEnglishMessage(args)
            doTrace = exitResult[1]
            return isExc, doTrace, msg

        msg, doTrace = exitResult
        return isExc, doTrace, msg
コード例 #9
0
 def bind (self, heads):
     self.columnBindings = [None] * heads.size()
     self.columnExecutors = [None] * len(self.columnBindings)
     i = 0
     classTypeDict = getattr(self.__class__, "_typeDict", {})
     extendedProcess = classTypeDict.get(".extendedLabelProcess")
     typeDict = self.getTargetClass()._typeDict
     dotMarkup = typeDict.get(".markup")
     dotDisplay = FitGlobal.getDiagnosticOption("displayLabelMapping")
     if dotDisplay is None:
         dotDisplay = (typeDict.get(".display") == "on")
     while heads:
         if extendedProcess == "on":
             try:
                 kind, name = self.processLabel(heads.text(), i)
             except Exception, e:
                 self.exception(heads, e)
                 heads = heads.more
                 i += 1
                 continue
             if kind == "continue":
                 name, kind = self._extractColumnTypeFromOldMarkup(name, typeDict)
             elif kind == "lookup":
                 kind = self._extractColumnTypeUsingMetadata(name, typeDict)
         elif dotMarkup == "off":
             name = self.camel(heads.text())
             kind = self._extractColumnTypeUsingMetadata(name, typeDict)
コード例 #10
0
 def doRows(self, rows):
     exceptionIfNone(rows, "ColumnHeadsMissing")
     self._shouldTakeExits = self._extractMetaData(".takeRowExits")
     if self._shouldTakeExits is None:
         self._shouldTakeExits = FitGlobal.appConfigInterface(
             "columnFixtureExits", rows)
     self.bind(rows.parts)
     super(ColumnFixture, self).doRows(rows.more)
コード例 #11
0
 def run(self, argv):
     result = self.args(argv)
     if not result:
         return result
     self.establishCommonTopLevelOptions(self.options,
                                         self._addToPythonPath)
     self.establishConnection(self._makeHttpRequest(),
                              self.host, self.port)
     self.validateConnection()
     FG.appConfigInterface("beforeRunExecution")
     self.executor = FitNesseTestExecutor(
         TablePrintingFixtureListener(),
         self.options)
     self.counts = self.executor.process(self._renameFileName)
     FG.appConfigInterface("afterRunExecution", self.counts)
     self.closeConnection()
     self.exit()
     return self.exitCode()
コード例 #12
0
ファイル: Fixture.py プロジェクト: copyleftdev/pyfit
 def doTable(self, table):
     shouldTakeExits = self._extractMetaData(".takeSetupExits")
     if shouldTakeExits is None:
         shouldTakeExits = FitGlobal.appConfigInterface(
             "fixtureSetUpExit", table)
     if shouldTakeExits is not False:
         self.setUpFixture(table.parts)
     self.doRows(table.parts.more)
     if shouldTakeExits is not False:
         self.tearDownFixture()
コード例 #13
0
 def doTable(self, table):
     shouldTakeExits = self._extractMetaData(".takeSetupExits")
     if shouldTakeExits is None:
         shouldTakeExits = FitGlobal.appConfigInterface(
             "fixtureSetUpExit", table)
     if shouldTakeExits is not False:
         self.setUpFixture(table.parts)
     self.doRows(table.parts.more)
     if shouldTakeExits is not False:
         self.tearDownFixture()
コード例 #14
0
 def run(self):
     FG.inFileName = FG.fsa.abspath(self.inFileName)
     FG.outFileName = FG.fsa.abspath(self.outFileName)
     head, tail = FG.fsa.split(self.inFileName)
     try:
         stack.push(head)
         self.parseTree = self.getParseTree(self.inFileName)
         self.parseTree = stack.wrapParseTree(self.parseTree)
         stack.pop()
     except Exception, e:
         FG.appConfigInterface("beforeTestExecution",
                                     FG.inFileName, e)
         conMsg.err("Unexpected Exception in parsing %s" % FG.inFileName)
         print "Unexpected Exception in parsing %s" % FG.inFileName
         exType, exInfo, exTrace = sys.exc_info()
         traceback.print_exception(exType, exInfo, exTrace,
                                   None, sys.stdout)
         traceback.print_exception(exType, exInfo, exTrace,
                                   None, conMsg)
         conTotal.fileResult(self.inFileName, Counts(0,0,0,1))
         return Counts(0,0,0,1)
 def handleParseException(self, e, docName):
     excClass, info, tb = sys.exc_info()
     traceList = traceback.format_exception(excClass, info, tb)
     trace = "".join(traceList)
     conMsg.tmsg("Parse exception occurred!: " + trace)
     html = "<table><tr><td>Unable to parse input. Input ignored</td></tr></table>"
     tables = Parse(html)
     tables.leader = docName + "\n" + tables.leader
     self.fixture.exception(tables, e)
     self.fixture.listener.createPage(tables)
     self.counts += self.fixture.counts
     try:
         self.fixture.listener.tableFinished(tables)
         self.fixture.listener.tablesFinished(self.counts)
     except:
         pass
     self.fixture.listener.writeCounts(self.fixture.counts,
                                       self.options.verbose)
     FG.appConfigInterface("afterTestExecution", self.fixture.counts,
                           self.fixture.summary)
     return
コード例 #16
0
 def run(self):
     FG.inFileName = FG.fsa.abspath(self.inFileName)
     FG.outFileName = FG.fsa.abspath(self.outFileName)
     head, tail = FG.fsa.split(self.inFileName)
     try:
         stack.push(head)
         self.parseTree = self.getParseTree(self.inFileName)
         self.parseTree = stack.wrapParseTree(self.parseTree)
         stack.pop()
     except Exception, e:
         FG.appConfigInterface("beforeTestExecution",
                                     FG.inFileName, e)
         conMsg.err("Unexpected Exception in parsing %s" % FG.inFileName)
         print "Unexpected Exception in parsing %s" % FG.inFileName
         exType, exInfo, exTrace = sys.exc_info()
         traceback.print_exception(exType, exInfo, exTrace,
                                   None, sys.stdout)
         traceback.print_exception(exType, exInfo, exTrace,
                                   None, conMsg)
         conTotal.fileResult(self.inFileName, Counts(0,0,0,1))
         return Counts(0,0,0,1)
コード例 #17
0
ファイル: taBase.py プロジェクト: copyleftdev/pyfit
 def __init__(self, instance, name, typeName, metaData = None):
     __pychecker__ = "no-noeffect" # two or stmts below
     super(FloatAdapter, self).__init__(instance, name, typeName,
                                        metaData = metaData)
     metaData = metaData or {}
     self.precision = metaData.get("%s.precision" % name) or 4
     self.charBounds = metaData.get("%s.charBounds" % name) or "5"
     self.checkOptions = "eer" # current default, change for 2.0???
     self.checkOptions = firstNonNone(FitGlobal.appConfigInterface(
                         "fpTypeAdapterCheck"), self.checkOptions)
     self.checkOptions = firstNonNone(metaData.get(
                         "%s.checkType" % name), self.checkOptions)
 def process(self, renamesFile=""):
     self._renameFileName = renamesFile
     self.fixture = Fixture()
     self.fixture.listener = self.fixtureListener
     self.fixture.listener.runner = self
     try:
         while True:
             try:
                 self._newFixture()
                 size = FitProtocol.readSize(netIn)
                 if not size: break
                 conMsg.tmsg("processing document of size: %s \n" % size)
                 document = FitProtocol.readDocument(netIn, size)
                 firstSep = document.find("\n")
                 if firstSep > -1:
                     docName = document[:firstSep]
                 else:
                     conMsg.emsg("Malformed Document received!. Exiting!")
                     raise Exception("Malformed Document received!")
                 conMsg.tmsg("new document: '%s'" % docName)
                 tables = Parse(document)
                 shouldExecute = FG.appConfigInterface(
                     "beforeTestExecution", docName, tables)
                 if shouldExecute is not False:
                     ##                        outDir = getattr(self.options, "outputDir", None)
                     ##                        if outDir:
                     ##                            docName = docName or "The Test"
                     ##                            FG.outFileName = (
                     ##                                "%s/%s.html" % (outDir, docName))
                     self.fixture.listener.createPage(tables)
                     self.fixture.doTables(tables)
                     self.fixture.listener.writeCounts(
                         self.fixture.counts, self.options.verbose)
                     self.counts += self.fixture.counts
                     FG.appConfigInterface("afterTestExecution",
                                           self.fixture.counts,
                                           self.fixture.summary)
             except ParseException, e:
                 self.handleParseException(e, docName)
         conMsg.tmsg("completion signal received\n")
コード例 #19
0
    def process(self, renamesFile=""):
        self._renameFileName = renamesFile
        self.fixture = Fixture()
        self.fixture.listener = self.fixtureListener
        self.fixture.listener.runner = self
        try:
            while True:
                try:
                    self._newFixture()
                    size = FitProtocol.readSize(netIn)
                    if not size: break
                    conMsg.tmsg("processing document of size: %s \n" % size)
                    document = FitProtocol.readDocument(netIn, size)
                    firstSep = document.find("\n")
                    if firstSep > -1:
                        docName = document[:firstSep]
                    else:
                        conMsg.emsg("Malformed Document received!. Exiting!")
                        raise Exception("Malformed Document received!")
                    conMsg.tmsg("new document: '%s'" % docName)
                    tables = Parse(document)
                    shouldExecute = FG.appConfigInterface(
                        "beforeTestExecution", docName, tables)
                    if shouldExecute is not False:
##                        outDir = getattr(self.options, "outputDir", None)
##                        if outDir:
##                            docName = docName or "The Test"
##                            FG.outFileName = (
##                                "%s/%s.html" % (outDir, docName))
                        self.fixture.listener.createPage(tables)
                        self.fixture.doTables(tables)
                        self.fixture.listener.writeCounts(
                            self.fixture.counts, self.options.verbose)
                        self.counts += self.fixture.counts
                        FG.appConfigInterface("afterTestExecution",
                                         self.fixture.counts,
                                         self.fixture.summary)
                except ParseException, e:
                    self.handleParseException(e, docName)
            conMsg.tmsg("completion signal received\n")
コード例 #20
0
 def handleParseException(self, e, docName):
     excClass, info, tb = sys.exc_info()
     traceList = traceback.format_exception(excClass, info, tb)
     trace = "".join(traceList)
     conMsg.tmsg("Parse exception occurred!: " + trace)
     html = "<table><tr><td>Unable to parse input. Input ignored</td></tr></table>"
     tables = Parse(html)
     tables.leader = docName + "\n" + tables.leader
     self.fixture.exception(tables, e)
     self.fixture.listener.createPage(tables)
     self.counts += self.fixture.counts
     try:
         self.fixture.listener.tableFinished(tables)
         self.fixture.listener.tablesFinished(self.counts)
     except:
         pass
     self.fixture.listener.writeCounts(
         self.fixture.counts, self.options.verbose)
     FG.appConfigInterface("afterTestExecution",
                      self.fixture.counts,
                      self.fixture.summary)
     return
コード例 #21
0
 def __init__(self, instance, name, typeName, metaData=None):
     __pychecker__ = "no-noeffect"  # two or stmts below
     super(FloatAdapter, self).__init__(instance,
                                        name,
                                        typeName,
                                        metaData=metaData)
     metaData = metaData or {}
     self.precision = metaData.get("%s.precision" % name) or 4
     self.charBounds = metaData.get("%s.charBounds" % name) or "5"
     self.checkOptions = "eer"  # current default, change for 2.0???
     self.checkOptions = firstNonNone(
         FitGlobal.appConfigInterface("fpTypeAdapterCheck"),
         self.checkOptions)
     self.checkOptions = firstNonNone(metaData.get("%s.checkType" % name),
                                      self.checkOptions)
コード例 #22
0
ファイル: Variations.py プロジェクト: copyleftdev/pyfit
 def mapLabel(self, label, kind=None, default=None):
     result = FitGlobal.appConfigInterface("mapLabel", label)
     if result is None or result[0] is None:
         pass
     elif result[0] == "done":
         return result[1]
     else:
         kind = result[1]
     kind = kind or default or "default"
     if kind == "camel":
         return self._camelLabelMapping(label)
     elif kind == "gracefulNames":
         return self._gracefulNamesLabelMapping(label)
     elif kind == "extended":
         return self._extendedLabelMapping(label)
     elif kind == "default":
         if FitGlobal.Environment == "FitNesse":
             return self._gracefulNamesLabelMapping(label)
         else:
             return self._camelLabelMapping(label)
     raise FitException("InvalidKindForMapLabel", kind)
コード例 #23
0
 def mapLabel(self, label, kind=None, default=None):
     result = FitGlobal.appConfigInterface("mapLabel", label)
     if result is None or result[0] is None:
         pass
     elif result[0] == "done":
         return result[1]
     else:
         kind = result[1]
     kind = kind or default or "default"
     if kind == "camel":
         return self._camelLabelMapping(label)
     elif kind == "gracefulNames":
         return self._gracefulNamesLabelMapping(label)
     elif kind == "extended":
         return self._extendedLabelMapping(label)
     elif kind == "default":
         if FitGlobal.Environment == "FitNesse":
             return self._gracefulNamesLabelMapping(label)
         else:
             return self._camelLabelMapping(label)
     raise FitException("InvalidKindForMapLabel", kind)
コード例 #24
0
ファイル: FixtureLoader.py プロジェクト: radiocutfm/pyfit
    def loadFixture(self, pathToClass, shouldBeAFixture = True):
        self.originalNameRequested = pathToClass
        newPath = FitGlobal.appConfigInterface("mapFixture", pathToClass)
        if newPath is not None:
            pathToClass = newPath
        else:
            if self.isGracefulName(pathToClass):
                pathToClass = self.unGracefulName(pathToClass)
            pathToClass = self._renameFixture(pathToClass)

        parts = pathToClass.split(".")
        if newPath is None and len(parts) == 1:
            for prefix in self._rememberedPackages:
                newParts = prefix.split(".") + parts
                newPath = ".".join(newParts)
                try:
                    result = self._loadModuleIsLastElement(newPath, newParts,
                                              shouldBeAFixture)
                except FitException:
                    continue
                return result
            result = self._loadModuleIsLastElement(pathToClass, parts,
                                                   shouldBeAFixture)
        elif len(parts) == 1:
            result = self._loadModuleIsLastElement(pathToClass, parts,
                                                   shouldBeAFixture)
        else:
            result = self._loadClassIsLastElement(pathToClass, parts,
                                                  shouldBeAFixture)
            packageName = ".".join(parts[:-2])
            if result is None:
                result = self._loadModuleIsLastElement(pathToClass, parts,
                                          shouldBeAFixture)
                packageName = ".".join(parts[:-1])
            self.rememberPackage(packageName)
        return result
コード例 #25
0
ファイル: MiscTest.py プロジェクト: copyleftdev/pyfit
 def shouldReturnNoneFromUnimplementedExit(self):
     exitResult = FitGlobal.appConfigInterface("unimplementedTestExit")
     assert exitResult is None
コード例 #26
0
ファイル: MiscTest.py プロジェクト: copyleftdev/pyfit
 def shouldReturnResultFromRealExit(self):
     exitResult = FitGlobal.appConfigInterface("mapErrorMessage",
                                 ("Test003",), None, None)
     assert exitResult == "It's magic!"
コード例 #27
0
 def shouldReturnNoneFromUnimplementedExit(self):
     exitResult = FitGlobal.appConfigInterface("unimplementedTestExit")
     assert exitResult is None
コード例 #28
0
    def parms(self, optv):
        self.options = Options(optv, BatchBase.parmDict, "BatchBase")
        # was self._parmDict
        opts = self.options
        FG.RunOptions = opts
        FG.Options = opts
        conMsg.setVerbose(opts.verbose)
        errMsgs = opts.eMsgs
        fileList = opts.posParms
        if not opts.isValid:
            for msg in errMsgs:
                conMsg.err(msg)
            self._usage()
            return False

        if opts.standardsLevel == "":
            FG.SpecificationLevel = "1.1"
        elif opts.standardsLevel != "1.1":
            conMsg.err("Standards level must be 1.1")
            FG.SpecificationLevel = "1.1"
        else:
            FG.SpecificationLevel = opts.standardsLevel

        if opts.standardMode is True:
            if opts.useCSS is True:
                conMsg.err("Standards mode requested. CSS output suppressed")
                opts.useCSS = False

        parmEditOK = ParmEditStatus()
        runType = "?"

        result = self._loadAppConfigurationModule(opts)
        if result is not True:
            conMsg.err(result)
            parmEditOK += False

        if 2 <= len(fileList) <= 3:
            self.inDir = FG.fsa.abspath(fileList[0])
            self.outDir = FG.fsa.abspath(fileList[1])
            statFile = FG.fsa.join(self.outDir, "FitStatistics.xml")
            if FG.fsa.isdir(self.inDir):
                self.inFile = None
                runType = "d"
                self._runObj = DirectoryRunner(self.inDir, self.outDir,
                                               self.options)
                if not FG.fsa.isdir(self.outDir):
                    conMsg.err(
                        "Output must be existing directory for input directory option")
                    parmEditOK += False
            elif (FG.fsa.isfile(self.inDir)):
                self.inFile = self.inDir
                self.inDir, tail = FG.fsa.split(self.inFile)
                root, ext = FG.fsa.splitext(self.inFile)
                if ext == ".txt":
                    if len(fileList) > 2:
                        conMsg.err(
                            "Rename File not allowed for list of files option")
                        parmEditOK += False
                    runType = "l"
                    self._runObj = FileListRunner(self.inFile, self.outDir,
                                                  self.options)
                    if not self.options.isValid:
                        for msg in self.options.eMsgs:
                            conMsg.err(msg)
                        self._usage()
                        return False
                        
                    parmEditOK += FG.appConfigInterface("listOfFilesOptions",
                                          self.options)
                    if not FG.fsa.isdir(self.outDir):
                        conMsg.err(
                            "Output must be existing directory for List of Files option")
                        parmEditOK += False
                else:
                    runType = "h"
                    self._runObj = HTMLRunner(self.inFile, self.outDir,
                                              self.options)
                    statFile = ""
                    head, tail = FG.fsa.split(self.outDir)
                    if not FG.fsa.isdir(head):
                        conMsg.err(
                            "Output directory for result file must exist.")
                        parmEditOK += False
                    else:
                        if FG.fsa.exists(self.outDir) and not FG.fsa.isfile(self.outDir):
                            conMsg.err(
                                "Output for single file option must be a file.")
                            parmEditOK += False
                    
            else:
                conMsg.err("'%s' does not exist!\n" % self.inDir)
                parmEditOK += False

        else:
            conMsg.err("Wrong number of positional parameters\n")
            parmEditOK += False

        # options from the "list of files" have been merged at this point
        parmEditOK += self._extractDiagnosticOptions(opts,
                                        FG.RunDiagnosticOptions)
        result = self._extractRunLevelSymbols(opts,
                                        FG.RunLevelSymbols)
        parmEditOK += result

        if len(fileList) == 3:
            loadOK = self._loadRenameFile(fileList[2])
            if not loadOK:
                conMsg.err("Rename file '%s' failed to load" % fileList[2])
            parmEditOK += loadOK
        else:
            default = FG.fsa.join(self.inDir, "FixtureRenames.txt")
            self._loadRenameFile(default)

        self.runType = runType
        Variations.returnVariation()

        if parmEditOK:
            self._setupStatisticsFile(runType, opts, statFile)
            self._setupConsoleStatisticsPrint(opts, runType)
            stack.init(opts)
            return True

        self._usage()
        return False
コード例 #29
0
 def shouldReturnResultFromRealExit(self):
     exitResult = FitGlobal.appConfigInterface("mapErrorMessage",
                                               ("Test003", ), None, None)
     assert exitResult == "It's magic!"
コード例 #30
0
class HTMLRunner(object):
    def __init__(self, inFileName, outFileName, options):
        self.inFileName = inFileName
        self.outFileName = outFileName
        self.options = options

#
# --------- phase 2 --- verify that the files exist.
#

    def verify(self):
        error = False        
        if not FG.fsa.isfile(self.inFileName):
            conMsg.err("%s does not exist!\n" % self.inFileName)
            error = True
        if FG.fsa.isdir(self.outFileName):
            head, tail = FG.fsa.split(self.inFileName)
            self.outFileName = FG.fsa.join(self.outFileName, tail)
        else:
            head, tail = FG.fsa.split(self.outFileName)
            if not FG.fsa.isdir(head):
                conMsg.err("%s is not a directory!" % head)
                error = True
        return not error

#
# -------- Phase 3 - Run the test.
#

    def run(self):
        FG.inFileName = FG.fsa.abspath(self.inFileName)
        FG.outFileName = FG.fsa.abspath(self.outFileName)
        head, tail = FG.fsa.split(self.inFileName)
        try:
            stack.push(head)
            self.parseTree = self.getParseTree(self.inFileName)
            self.parseTree = stack.wrapParseTree(self.parseTree)
            stack.pop()
        except Exception, e:
            FG.appConfigInterface("beforeTestExecution",
                                        FG.inFileName, e)
            conMsg.err("Unexpected Exception in parsing %s" % FG.inFileName)
            print "Unexpected Exception in parsing %s" % FG.inFileName
            exType, exInfo, exTrace = sys.exc_info()
            traceback.print_exception(exType, exInfo, exTrace,
                                      None, sys.stdout)
            traceback.print_exception(exType, exInfo, exTrace,
                                      None, conMsg)
            conTotal.fileResult(self.inFileName, Counts(0,0,0,1))
            return Counts(0,0,0,1)

        shouldExecute = FG.appConfigInterface("beforeTestExecution",
                                        FG.inFileName, self.parseTree)
        if shouldExecute in (True, None):
            self.fixture = Fixture()
            self.fixture.summary["input file"] = FG.inFileName
            self.fixture.summary["input update"] = FG.fsa.timeUpdated(self.inFileName)
            self.fixture.summary["output file"] = FG.outFileName
            self.fixture.doTables(self.parseTree)
            if self.options.outputEncodingForce:
                self.encoding = self.options.outputEncodingForce
                self.encodingType = "OutputOverride"
            if self.options.useCSS:
                outDir, foo = FG.fsa.split(FG.outFileName)
                self._createFitCSSFile(outDir)
                self._addCSSStuffToHeader(self.parseTree)
            self._fixMetaTag(self.parseTree, self.encoding, self.encodingType)
            textOut = self.parseTree.toString()
            self.write(textOut, self.encoding)
            FG.appConfigInterface("afterTestExecution",
                                         self.fixture.counts,
                                         self.fixture.summary)
            conTotal.fileResult(self.inFileName, self.fixture.counts)
            stats.reportStats(FG.inFileName, self.fixture.counts,
                              self.fixture.summary)
            return self.fixture.counts
        else:
            counts = Counts(0,0,1)
            summary = {}
            summary["input file"] = FG.inFileName
            summary["input update"] = FG.fsa.timeUpdated(self.inFileName)
            summary["output file"] = FG.outFileName
            stats.reportStats(FG.inFileName, None, summary)
            conTotal.fileResult(FG.inFileName, None)
            return counts
コード例 #31
0
ファイル: MiscTest.py プロジェクト: copyleftdev/pyfit
 def shouldReturnNoneIfNoExitIsInstalled(self):
     self._setAppConfig((None, None, None, None))
     exitResult = FitGlobal.appConfigInterface("mapErrorMessage",
                                 ("Test003",), None, None)
     assert exitResult is None
コード例 #32
0
    def parms(self, optv):
        self.options = Options(optv, BatchBase.parmDict, "BatchBase")
        # was self._parmDict
        opts = self.options
        FG.RunOptions = opts
        FG.Options = opts
        conMsg.setVerbose(opts.verbose)
        errMsgs = opts.eMsgs
        fileList = opts.posParms
        if not opts.isValid:
            for msg in errMsgs:
                conMsg.err(msg)
            self._usage()
            return False

        if opts.standardsLevel == "":
            FG.SpecificationLevel = "1.1"
        elif opts.standardsLevel != "1.1":
            conMsg.err("Standards level must be 1.1")
            FG.SpecificationLevel = "1.1"
        else:
            FG.SpecificationLevel = opts.standardsLevel

        if opts.standardMode is True:
            if opts.useCSS is True:
                conMsg.err("Standards mode requested. CSS output suppressed")
                opts.useCSS = False

        parmEditOK = ParmEditStatus()
        runType = "?"

        result = self._loadAppConfigurationModule(opts)
        if result is not True:
            conMsg.err(result)
            parmEditOK += False

        if 2 <= len(fileList) <= 3:
            self.inDir = FG.fsa.abspath(fileList[0])
            self.outDir = FG.fsa.abspath(fileList[1])
            statFile = FG.fsa.join(self.outDir, "FitStatistics.xml")
            if FG.fsa.isdir(self.inDir):
                self.inFile = None
                runType = "d"
                self._runObj = DirectoryRunner(self.inDir, self.outDir,
                                               self.options)
                if not FG.fsa.isdir(self.outDir):
                    conMsg.err(
                        "Output must be existing directory for input directory option")
                    parmEditOK += False
            elif (FG.fsa.isfile(self.inDir)):
                self.inFile = self.inDir
                self.inDir, tail = FG.fsa.split(self.inFile)
                root, ext = FG.fsa.splitext(self.inFile)
                if ext == ".txt":
                    if len(fileList) > 2:
                        conMsg.err(
                            "Rename File not allowed for list of files option")
                        parmEditOK += False
                    runType = "l"
                    self._runObj = FileListRunner(self.inFile, self.outDir,
                                                  self.options)
                    if not self.options.isValid:
                        for msg in self.options.eMsgs:
                            conMsg.err(msg)
                        self._usage()
                        return False
                        
                    parmEditOK += FG.appConfigInterface("listOfFilesOptions",
                                          self.options)
                    if not FG.fsa.isdir(self.outDir):
                        conMsg.err(
                            "Output must be existing directory for List of Files option")
                        parmEditOK += False
                else:
                    runType = "h"
                    self._runObj = HTMLRunner(self.inFile, self.outDir,
                                              self.options)
                    statFile = ""
                    head, tail = FG.fsa.split(self.outDir)
                    if not FG.fsa.isdir(head):
                        conMsg.err(
                            "Output directory for result file must exist.")
                        parmEditOK += False
                    else:
                        if FG.fsa.exists(self.outDir) and not FG.fsa.isfile(self.outDir):
                            conMsg.err(
                                "Output for single file option must be a file.")
                            parmEditOK += False
                    
            else:
                conMsg.err("'%s' does not exist!\n" % self.inDir)
                parmEditOK += False

        else:
            conMsg.err("Wrong number of positional parameters\n")
            parmEditOK += False

        # options from the "list of files" have been merged at this point
        parmEditOK += self._extractDiagnosticOptions(opts,
                                        FG.RunDiagnosticOptions)
        result = self._extractRunLevelSymbols(opts,
                                        FG.RunLevelSymbols)
        parmEditOK += result

        if len(fileList) == 3:
            loadOK = self._loadRenameFile(fileList[2])
            if not loadOK:
                conMsg.err("Rename file '%s' failed to load" % fileList[2])
            parmEditOK += loadOK
        else:
            default = FG.fsa.join(self.inDir, "FixtureRenames.txt")
            self._loadRenameFile(default)

        self.runType = runType
        Variations.returnVariation()

        if parmEditOK:
            self._setupStatisticsFile(runType, opts, statFile)
            self._setupConsoleStatisticsPrint(opts, runType)
            stack.init(opts)
            return True

        self._usage()
        return False
コード例 #33
0
 def shouldReturnNoneIfNoExitIsInstalled(self):
     self._setAppConfig((None, None, None, None))
     exitResult = FitGlobal.appConfigInterface("mapErrorMessage",
                                               ("Test003", ), None, None)
     assert exitResult is None