当前位置: 首页>>代码示例>>Python>>正文


Python Parse.Parse类代码示例

本文整理汇总了Python中fit.Parse.Parse的典型用法代码示例。如果您正苦于以下问题:Python Parse类的具体用法?Python Parse怎么用?Python Parse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Parse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: shouldBeAbleToColorExceptionAsWrong

 def shouldBeAbleToColorExceptionAsWrong(self):
     fix = Fixture()
     cell = Parse(tag="td", body="Oops.")
     fix.exception(cell, "What the heck?", color="wrong")
     assert cell.body.find("What the heck?") > -1
     assert cell.tagIsWrong()
     assert fix.counts.wrong == 1
开发者ID:copyleftdev,项目名称:pyfit,代码行数:7,代码来源:FixtureTest.py

示例2: shouldHandleStringAsExceptionParameter

 def shouldHandleStringAsExceptionParameter(self):
     fix = Fixture()
     cell = Parse(tag="td", body="Oops.")
     fix.exception(cell, "What the heck?")
     assert cell.body.find("What the heck?") > -1
     assert cell.tagIsError()
     assert fix.counts.exceptions == 1
开发者ID:copyleftdev,项目名称:pyfit,代码行数:7,代码来源:FixtureTest.py

示例3: buildRows

 def buildRows(self, rows):
     root = Parse(tag="xx")
     for row in rows:
         newRow = Parse(tag="tr", parts=self.buildCells(row))
         newRow.more = root.more
         root.more = newRow
     return root.more
开发者ID:copyleftdev,项目名称:pyfit,代码行数:7,代码来源:RowFixture.py

示例4: shouldRecognizeFitFailureException

 def shouldRecognizeFitFailureException(self):        
     fix = Fixture()
     cell = Parse(tag="td", body="Oops.")
     fix.exception(cell, FitFailureException("What the heck?"))
     assert cell.body.find("What the heck?") > -1
     assert cell.tagIsError()
     assert fix.counts.exceptions == 1
开发者ID:copyleftdev,项目名称:pyfit,代码行数:7,代码来源:FixtureTest.py

示例5: performTest

    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)
开发者ID:copyleftdev,项目名称:pyfit,代码行数:28,代码来源:Tests.py

示例6: shouldAnnotateOnErrorCall

 def shouldAnnotateOnErrorCall(self):
     fix = Fixture()
     cell = Parse(tag="td", body="Oops.")
     fix.error(cell, "Not good!")
     assert cell.body.find("Not good!") > -1
     assert cell.tagIsError()
     assert fix.counts.exceptions == 1
开发者ID:copyleftdev,项目名称:pyfit,代码行数:7,代码来源:FixtureTest.py

示例7: testToPrint

 def testToPrint(self):
     text = (
         "leader<table><tr><td><table><tr><td>body1</td></tr></table>"
         "<table><tr><td>body2</td></tr></table></td></tr></table>"
         "trailer"
     )
     p = Parse(text)
     newText = p.toPrint()
     assert newText == text
开发者ID:copyleftdev,项目名称:pyfit,代码行数:9,代码来源:ParseTest.py

示例8: testToPrintUnicode

 def testToPrintUnicode(self):
     text = (
         u"leader<table><tr><td><table><tr><td>body1</td></tr></table>"
         u"<table><tr><td>body2</td></tr></table></td></tr></table>"
         u"trailer"
     )
     p = Parse(text)
     newText = p.toPrint()
     assert newText == text
     assert isinstance(newText, types.StringType)
开发者ID:copyleftdev,项目名称:pyfit,代码行数:10,代码来源:ParseTest.py

示例9: copyParse

def copyParse(tables):
        if tables is None:
            return None
        parse = Parse(tag="", body=tables.body,
                parts=copyParse(tables.parts), more=copyParse(tables.more))
        parse.tag = tables.tag
        parse.end = tables.end
        parse.leader = tables.leader
        parse.trailer = tables.trailer
        return parse
开发者ID:copyleftdev,项目名称:pyfit,代码行数:10,代码来源:ParseUtility.py

示例10: shouldUseWithTypeAdapter

 def shouldUseWithTypeAdapter(self):
     obj = MockObject()
     givenTA = TypeAdapter.on(obj, "sFloat1")
     givenCell = Parse(tag="td", body="6.45")
     obj.parseAndSet(givenCell, givenTA)
     assert obj.sFloat1 == 6.45
     assert isinstance(obj.sFloat1, ScientificFloat)
     assert givenCell.tagIsNotAnnotated()
     resultTA = TypeAdapter.on(obj, "sFloat2")
     resultCell = Parse(tag="td", body="6.45")
     obj.check(resultCell, resultTA)
     assert resultCell.tagIsRight()
开发者ID:copyleftdev,项目名称:pyfit,代码行数:12,代码来源:MiscTest.py

示例11: testSymbolHandler

 def testSymbolHandler(self):
     h = SymbolCellHandler()
     checkCell = Parse(tag="td", body="&lt;&lt;sym")
     parseCell = Parse(tag="td", body="sym&lt;&lt;")
     callbacks = AccMock(IntMock())
     result = h.check(checkCell, "spam", callbacks)
     assert result == (OK, True)
     assert callbacks.fixture.getSymbol("sym") == "spam"
     assert checkCell.text().endswith(" = spam")
     result = h.parse(parseCell, callbacks)
     assert result == (OK, "spam")
     assert parseCell.text().endswith(" = spam")
开发者ID:copyleftdev,项目名称:pyfit,代码行数:12,代码来源:CellHandlerTest.py

示例12: buildSurplusCells

 def buildSurplusCells(self, adapters, objectOrDict):
     root = Parse(tag="xx")
     next = root
     for adapter, name, symbols in adapters:
         hasKey, obj = self._getObj(name, objectOrDict)
         cell = Parse(tag="td")
         if hasKey:
             cell.body = adapter.toString(obj)
         else:
             self.exception(cell, "attribute missing")
         next.more = cell
         next = cell
     return root.more
开发者ID:copyleftdev,项目名称:pyfit,代码行数:13,代码来源:ArrayFixture.py

示例13: run

 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
开发者ID:copyleftdev,项目名称:pyfit,代码行数:14,代码来源:ExampleTests.py

示例14: Table

class Table(TableInterface):
    _parse = None # Parse

    def __init__(self, parse):
        if isinstance(parse, types.StringTypes):
            self._parse = Parse(parse)
        elif isinstance(parse, Parse):
            self._parse = parse

    def tableAt(self, i, j, k):
        at = self._parse.at(i, j, k).parts
        return Table(at)

    def stringAt(self, i, j, k):
        p2 = self._parse.at(i, j, k)
        if p2.parts or not p2.body:
            return "null"
        return p2.text()

    def toTable(self):
        return self

    def parseTable(parse):
        return Table(parse)
    parseTable = staticmethod(parseTable)

    def equals(expected, actual):
        if expected is None:
            return actual is None
        return expected == actual
    equals = staticmethod(equals)

    def __eq__(self, other):
        if not isinstance(other, Table):
            return False
        return self._parse == other._parse

    def __ne__(self, other):
        if isinstance(other, Table):
            return False
        return self._parse != other._parse

    def toString(self):
        return self._parse.toString()

    def __str__(self):
        return str(self._parse)
开发者ID:copyleftdev,项目名称:pyfit,代码行数:47,代码来源:Table.py

示例15: buildCells

 def buildCells(self, row):
     if not row:
         nil = Parse(tag="td",body="None",parts=None,more=None)
         nil.addToTag(" colspan="+str(len(self.columnBindings)))
         return nil
     next = root = Parse(None, None, None, None)
     for i in range(len(self.columnBindings)):
         next.more = Parse(tag="td",body="&nbsp;",parts=None,more=None)
         next = next.more
         a = self.columnBindings[i]
         if not a:
             self.ignore(next)
         else:
             try:
                 a.target = row
                 next.body = self.gray(self.escape(a.toString(a.get())))
             except Exception, e:
                 self.exception(next, e)
开发者ID:zhukovaskychina,项目名称:httpautomation,代码行数:18,代码来源:RowFixture.py


注:本文中的fit.Parse.Parse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。