示例#1
0
文件: Tests.py 项目: radiocutfm/pyfit
    def performTest(self, cell, runscript, page):
        if ((runscript is None or runscript == "null") or page.startswith("?")):
            self.ignore(cell)
            return
        try:
            fileName = cell.text()
            testResult = self.get(fileName)
            if testResult.find("<wiki>") >= 0:
                data = Parse(testResult, ("wiki", "td")).parts
            else:
                data = Parse(testResult, ("td",))
            c = self.count(data)
                               
            message = self.anchor("  %s/%s/%s&nbsp;" %
                                  (c.right, c.wrong, c.exceptions), fileName)

            cell.addToBody(message);
            if c.right > 0 and c.wrong == 0 and c.exceptions == 0:
                self.right(cell)
            else: 
                self.wrong(cell)
                cell.addToBody(data.footnote()); # XXX see note about footnotes.
        except Exception, e:
            if str(e).find("Can't find tag: td") >= 0:
                cell.addToBody("Can't parse <a href=\"" + testResult + "\">page</a>")
                self.ignore(cell)
            else:
                self.exception(cell, e)
示例#2
0
 def run(self, path, fixture, cells):
     if self.pushAndCheck(path):
         self.ignore(cells)
         self.info(cells, "recursive")
         return
     try:
         theTest = self.read(path)
         if theTest.find("<wiki>") >= 0:
             tags=["wiki", "table", "tr", "td"]
         else:
             tags=["table", "tr", "td"]
         tables = Parse(text=theTest, tags=tags)
         fixture.doTables(tables)
         self.info(cells.more, fixture.counts.toString())
         if fixture.counts.wrong == 0 and fixture.counts.exceptions == 0:
             self.right(cells.more)
         else:
             self.wrong(cells.more)
             cells.more.addToBody(tables.footnote())
     except Exception, e:
         self.exception(cells, e)
示例#3
0
 def run(self, path, fixture, cells):
     if self.pushAndCheck(path):
         self.ignore(cells)
         self.info(cells, "recursive")
         return
     try:
         theTest = self.read(path)
         if theTest.find("<wiki>") >= 0:
             tags=["wiki", "table", "tr", "td"]
         else:
             tags=["table", "tr", "td"]
         tables = Parse(text=theTest, tags=tags)
         fixture.doTables(tables)
         self.info(cells.more, fixture.counts.toString())
         if fixture.counts.wrong == 0 and fixture.counts.exceptions == 0:
             self.right(cells.more)
         else:
             self.wrong(cells.more)
             cells.more.addToBody(tables.footnote())
     except Exception, e:
         self.exception(cells, e)
class ExampleTests(ColumnFixture):
    fileName = ""
    wiki = 0
    _typeDict = {
        "fileName": "String",
        "file.renameTo": "fileName",
        "wiki": "Boolean"
    }

    def __init__(self):
        ColumnFixture.__init__(self)
        self.fileName = ""
        self.wiki = 0
        self.input = ""
        self.tables = None
        self.fixture = None
        self.runCounts = Counts()
        self.footnote = None
        self.fileCell = None

    def run(self):
        newFileName = "fat/Documents/" + self.fileName
        inFile = open(newFileName, 'r')
        theTest = inFile.read()
        inFile.close()
        self.fixture = Fixture()
        self.footnote = None
        if self.wiki:
            self.tables = Parse(text=theTest,
                                tags=("wiki", "table", "tr", "td"))
        else:
            self.tables = Parse(text=theTest, tags=("table", "tr", "td"))
        self.fixture.doTables(self.tables)
        self.runCounts.tally(self.fixture.counts)
        self.summary["counts run"] = self.runCounts

    _typeDict["right_"] = "Int"
    _typeDict["right.renameTo"] = "right_"

    def right_(self):
        self.run()
        return self.fixture.counts.right

    _typeDict["wrong_"] = "Int"
    _typeDict["wrong.renameTo"] = "wrong_"

    def wrong_(self):
        return self.fixture.counts.wrong

    _typeDict["ignores"] = "Int"

    def ignores(self):
        return self.fixture.counts.ignores

    _typeDict["exceptions"] = "Int"

    def exceptions(self):
        return self.fixture.counts.exceptions

    def doRow(self, row):
        self.fileCell = row.leaf()
        ColumnFixture.doRow(self, row)

    def wrong(self, cell, actual=None, escape=True):
        #        super(ExampleTests, self)
        ColumnFixture.wrong(self, cell, actual=actual, escape=escape)
        if self.footnote == None:
            self.footnote = self.tables.footnote()
            self.fileCell.addToBody(self.footnote)
示例#5
0
class ExampleTests(ColumnFixture):
    fileName = ""
    wiki = 0
    _typeDict = {"fileName": "String",
                 "file.renameTo": "fileName",
                 "wiki": "Boolean"}
        
    def __init__(self):
        ColumnFixture.__init__(self)
        self.fileName = ""
        self.wiki = 0
        self.input = ""
        self.tables = None
        self.fixture = None
        self.runCounts = Counts()
        self.footnote = None
        self.fileCell = None

    def run(self):
        newFileName = "fat/Documents/" + self.fileName
        inFile = open(newFileName, 'r')
        theTest = inFile.read()
        inFile.close()
        self.fixture = Fixture()
        self.footnote = None
        if self.wiki:
            self.tables = Parse(text=theTest, tags=("wiki", "table", "tr", "td"))
        else:
            self.tables = Parse(text=theTest, tags=("table", "tr", "td"))
        self.fixture.doTables(self.tables)
        self.runCounts.tally(self.fixture.counts)
        self.summary["counts run"] = self.runCounts

    _typeDict["right_"] = "Int"
    _typeDict["right.renameTo"] = "right_"
    def right_(self):
        self.run()
        return self.fixture.counts.right

    _typeDict["wrong_"] = "Int"
    _typeDict["wrong.renameTo"] = "wrong_"
    def wrong_(self):
        return self.fixture.counts.wrong

    _typeDict["ignores"] = "Int"
    def ignores(self):
        return self.fixture.counts.ignores

    _typeDict["exceptions"] = "Int"
    def exceptions(self):
        return self.fixture.counts.exceptions

    def doRow(self, row):
        self.fileCell = row.leaf()
        ColumnFixture.doRow(self, row)

    def wrong(self, cell, actual = None, escape=True):
#        super(ExampleTests, self)
        ColumnFixture.wrong(self, cell, actual = actual, escape = escape)
        if self.footnote == None:
            self.footnote = self.tables.footnote()
            self.fileCell.addToBody(self.footnote)