Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 def testUnescape(self):
     self.assertEquals("a<b", Parse().unescape("a&lt;b"))
     self.assertEquals("a>b & b>c &&",
                       Parse().unescape("a&gt;b&nbsp;&amp;&nbsp;b>c &&"))
     self.assertEquals("&amp;&amp;", Parse().unescape("&amp;amp;&amp;amp;"))
     self.assertEquals("a>b & b>c &&",
                       Parse().unescape("a&gt;b&nbsp;&amp;&nbsp;b>c &&"))
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 def _createLabelRow(self, labels):
     first = Parse(tag="td")
     last = first
     for label in labels:
         last.more = Parse(tag="td", body=label)
         last = last.more
     return first.more
Exemplo n.º 11
0
 def makeCells(self, text):
     parts = text.split("|")
     firstCell = lastCell = Parse(tag="td")
     for body in parts:
         lastCell.more = Parse(tag="td", body=body)
         lastCell = lastCell.more
     return firstCell.more
Exemplo n.º 12
0
 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
Exemplo n.º 13
0
 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
Exemplo n.º 14
0
 def buildHeaderRow(self, nameList):
     head = Parse(tag="xx")
     current = head
     for name in nameList:
         current.more = Parse(tag="td", body=name)
         current = current.more
     return Parse(tag="tr", parts=head.more)
Exemplo n.º 15
0
 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
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 def doTable(self, table):
     handlerList = TypeAdapter.getCurrentCellHandlerList()
     lastrow = table.parts
     for handler in handlerList:
         lastrow.more = Parse(tag="tr",
                              parts=Parse(tag="td",
                                          body=handler.__class__.__name__))
         lastrow = lastrow.more
Exemplo n.º 18
0
 def buildSurplusRows(self, adapters, actuals):
     root = Parse(tag="xx")
     next = root
     for objectOrDict in actuals:
         newRow = self.buildSurplusCells(adapters, objectOrDict)
         newRowCell = Parse(tag="tr", parts=newRow)
         next.more = newRowCell
         next = newRowCell
     return root.more
Exemplo n.º 19
0
 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
Exemplo n.º 20
0
 def buildRows(self, rows):
     next = root = Parse(None, None, None, None)
     for row in rows:
         next.more = Parse(tag="tr",
                           body=None,
                           parts=self.buildCells(row),
                           more=None)
         next = next.more
     return root.more
Exemplo n.º 21
0
 def addRows(self):
     nextRow = self.row.more
     self.row.more = Parse(tag="tr",
                           body="",
                           parts=self.newRows(),
                           more=Parse(tag="tr",
                                      body="",
                                      parts=self.newRows(),
                                      more=nextRow))
Exemplo n.º 22
0
 def testEquals(self):
     text = ("leader<table><tr><td><table><tr><td>body1</td></tr></table>"
             "<table><tr><td>body2</td></tr></table></td></tr></table>"
             "trailer")
     p1 = Parse(text)
     p2 = Parse(text)
     assert p1 == p2
     assert (p1 != p2) is False
     assert (p1 == None) is False
     assert (p1 == 42) is False
Exemplo n.º 23
0
 def testSymbolHandlerWithNoSymbol(self):
     h = SymbolCellHandler()
     checkCell = Parse(tag="td", body="sym")
     parseCell = Parse(tag="td", body="sym")
     callbacks = AccMock(IntMock())
     result = h.check(checkCell, "spam", callbacks)
     assert result == (NEXT, None)
     self.failUnlessRaises(KeyError, callbacks.fixture.getSymbol, "sym")
     result = h.parse(parseCell, callbacks)
     assert result == (NEXT, None)
Exemplo n.º 24
0
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
Exemplo n.º 25
0
 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)
 def _makeCellsWithTd(self, actuals):
     if not len(actuals):
         aCell = Parse(tag="tr")
         self.exception(aCell, "Actuals Row Empty")
         return aCell
     rows = Parse(tag="td")
     row = rows
     for i in range(len(actuals)):
         row.more = self._makeCell(actuals[i])
         row = row.more
     return rows.more
Exemplo n.º 27
0
def addRowToTable(table, cells):
    if type(cells) != type([]):
        cells = [cells]
    if not len(cells):
        raise ValueError("Can't have an empty row.")  # xxx better exception!
    root = Parse(tag="td", body="fake anchor")
    here = root
    for cell in cells:
        here.more = Parse(tag="td", body=cell)
        here = here.more
    table.parts.last().more = Parse(tag="tr", body="", more=root.more)
Exemplo n.º 28
0
 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()
Exemplo n.º 29
0
 def makeEmbeddedRows(self, rows):
     allEmbeddedRows = Parse(tag="tr")
     embeddedRow = allEmbeddedRows
     while rows is not None:
         cells = rows.parts
         if (not cells.text() == "report" and cells.more is not None
                 and not cells.text().startswith("I")):
             embeddedRow.more = Parse(tag="tr",
                                      parts=cells.more)  #drop first column
             embeddedRow = embeddedRow.more
         rows = rows.more
     return Parse(tag="table", parts=allEmbeddedRows.more)
Exemplo n.º 30
0
 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")
Exemplo n.º 31
0
 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
Exemplo n.º 32
0
 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
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)
Exemplo n.º 34
0
 def _checkTest(self, method, cellContent, resultObjName):
     obj = testClass()
     adapter = ta.on(obj, method)
     cell = Parse(tag="td", body=cellContent)
     checkResult = adapter.check(cell)
     assert checkResult.__class__.__name__ == resultObjName
     return checkResult
Exemplo n.º 35
0
 def checkMarkup(self, label, adapter, accessor, type, identifier):
     heads = Parse(tag="td", body=label)
     self.obj.bind(heads)
     self.mustBeEqual(self.obj.columnExecutors[0], adapter)
     self.mustBeTA(self.obj.columnBindings[0], accessor, type)
     newId, colType = self.obj._extractColumnTypeFromOldMarkup(label, {})
     assert newId == identifier
Exemplo n.º 36
0
 def shouldPostErrorOnFirstTable(self):
     fix = MockRaisesErrorOnDoTable()
     table = Parse("<table><tr><td>"
         "tests.FixtureTest.MockRaisesErrorOnDoTable</td></tr></table>")
     fix.doTables(table)
     cell = table.parts.parts
     assert cell.tagIsError()
 def _addActualRows(self, rows, actual):
     cols = 0
     lastRow = rows
     while rows:
         lastRow = rows
         cols = max(cols, lastRow.size())
         rows = rows.more
     for i in range(len(actual)):
         cols = max(cols, len(actual[i]))
     lastRow.more = Parse(tag="tr",
                          parts=Parse(tag="td colspan=%s" % cols,
                                      body="<i>Actuals:</i>"))
     lastRow = lastRow.more
     for i in range(len(actual)):
         lastRow.more = self._makeRowWithTr(actual[i])
         lastRow = lastRow.more
Exemplo n.º 38
0
 def shouldPutMessageInCellForUnprintableAttributeInSurplusRow(self):
     table = Parse("<table><tr><td>fit.RowFixture</td></tr>"
                   "<tr><td>c1</td><td>Huh</td><td>c3</td></tr>"
                   "<tr><td>Three</td><td>Blind</td><td>Mice</td></tr>"
                   "<tr><td>Lord</td><td>Lova</td><td>Duck</td></tr>"
                   "<tr><td>Larry</td><td>Moe</td><td>Curly</td></tr>"
                   "</table>")
     coll = [
         ProcObj("Three", "Blind", "Mice"),
         ProcObj("Lord", "Lova", "Duck"), {
             "c1": "Larry",
             "Huh": "Moe",
             "c3": "Curly"
         }, {
             "c1": "Larry",
             "Huh": u"\u00a1",
             "c3": "Curly"
         }
     ]
     coll[0].Huh = "Blind"
     coll[1].Huh = "says to"
     metaData = {"c1": "String", "c2": "String", "c3": "String"}
     fix = RowFixture(coll, metaData)
     fix.doTable(table)
     ##        em("\n%s" % table.toNodeList())
     cell = table.parts.more.more.more.more.more.parts.more
     ##        em("tag: %s body: %s" % (cell.tag, cell.body))
     assert cell.body.find("[error extracting value]") > -1
     assert fix.counts == Counts(8, 2, 0, 1)
Exemplo n.º 39
0
 def doRows(self, rows):
     #this.table = new Parse ("table", null, copy(rows), null);
     #// evaluate the rest of the table like a runner
     #(new Fixture()).doTables(this.table);
     table = Parse(tag="table", body="", parts=self.copy(rows), more=None)
     self.setSymbol("Table", table)
     Fixture().doTables(table)
Exemplo n.º 40
0
 def shouldMarkIncorrectSymbolReferenceAsWrong(self):
     table = Parse("<table><tr><td>fit.RowFixture</td></tr>"
                   "<tr><td>c1</td><td>c2</td><td>c3=</td></tr>"
                   "<tr><td>Three</td><td>Blind</td><td>a</td></tr>"
                   "<tr><td>Lord</td><td>Lova</td><td>b</td></tr>"
                   "<tr><td>Larry</td><td>Moe</td><td>c</td></tr>"
                   "</table>")
     coll = [
         ProcObj("Three", "Blind", "Mice"),
         ProcObj("Lord", "Lova", "Duck"), {
             "c1": "Larry",
             "c2": "Moe",
             "c3": "Curly"
         }
     ]
     metaData = {"c1": "String", "c2": "String", "c3": "String"}
     fix = RowFixture(coll, metaData)
     fix.setSymbol("a", "Mice")
     fix.setSymbol("b", "Duck")
     fix.setSymbol("c", "Laurel")
     fix.doTable(table)
     ##        label1 = table.parts.more.parts
     ##        em("\n%s" % table.toNodeList())
     ##        cell = table.parts.more.more.more.more.parts.more.more
     ##        em("tag: %s body: %s" % (cell.tag, cell.body))
     assert fix.counts == Counts(8, 1)
Exemplo n.º 41
0
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)
Exemplo n.º 42
0
 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)
Exemplo n.º 43
0
 def testText(self):
     tags = ("td",)
     print "----- in testText"
     p = Parse("<td>a&lt;b</td>", tags)
     self.assertEquals("a&lt;b", p.body)
     self.assertEquals("a<b", p.text())
     p = Parse("<td>\ta&gt;b&nbsp;&amp;&nbsp;b>c &&&nbsp;</td>", tags)
     self.assertEquals("a>b & b>c &&", p.text())
     p = Parse("<td>\ta&gt;b&nbsp;&amp;&nbsp;b>c &&nbsp;</td>", tags)
     self.assertEquals("a>b & b>c &", p.text())
     p = Parse('<TD><P><FONT FACE="Arial" SIZE=2>GroupTestFixture</FONT></TD>', tags)
     self.assertEquals("GroupTestFixture", p.text())
Exemplo n.º 44
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)
Exemplo n.º 45
0
class TestEditedStringProtocolCompatability(unittest.TestCase):
    def setUp(self):
        self.ta = tat["Float"](self, "aFloatVar", "Float", metaData={})
        self.pro = taPro.getProtocolFor(self.ta)
        self.cell = Parse(tag="td", body="3.14")
        print '%s %s' % (self.id(), self.shortDescription())

    def testProtocolForFloatAdapter(self):
        assert isinstance(self.pro, taPro.EditedStringProtocol)
        assert isinstance(self.pro.ta, taType)
        assert self.pro.ta.fitAdapterProtocol == "EditedString"

    def testEditedStringProtocolParse(self):
        self.assertAlmostEqual(self.pro.parse(self.cell.text()), 3.14, 1)

    def testEditedStringProtocolEquals(self):
        obj = self.pro.parse(self.cell)
        assert self.pro.equals(self.cell.text(), obj)

    def testEditedStringProtocolToString(self):
        obj = self.pro.parse(self.cell)
        assert self.pro.toString(obj) == "3.14"        
Exemplo n.º 46
0
class TestBasicProtocolCompatability(unittest.TestCase):
    def setUp(self):
        self.ta = tat["String"](self, "aStringVar", "String")
        self.pro = taPro.getProtocolFor(self.ta)
        self.cell = Parse(tag="td", body="spam")
        print '%s %s' % (self.id(), self.shortDescription())

    def testProtocolForStringAdapter1(self):
        assert isinstance(self.pro, taPro.BasicProtocol)
        assert isinstance(self.pro.ta, taType)
        assert self.pro.ta.fitAdapterProtocol == "Basic"

    def testBasicProtocolParse(self):
        assert self.pro.parse(self.cell.text()) == "spam"

    def testBasicProtocolEquals(self):
        obj = self.pro.parse(self.cell.text())
        assert self.pro.equals(self.cell.text(), obj)

    def testBasicProtocolToString(self):
        obj = self.pro.parse(self.cell)
        assert self.pro.toString(obj) == "spam"
Exemplo n.º 47
0
class TestApplicationProtocolCompatability(unittest.TestCase):
    def setUp(self):
        self.ta = ScientificFloat
        self.pro = taPro.getProtocolFor(self.ta)
        self.cell = Parse(tag="td", body="2.798")
        print '%s %s' % (self.id(), self.shortDescription())

    def testProtocolForPrimitiveState(self):
        assert isinstance(self.pro, taPro.ApplicationProtocol)
        assert not isinstance(self.pro.ta, taType)

    def testApplicationProtocolParse(self):
        self.assertAlmostEqual(self.pro.parse(self.cell.text()), 2.798, 3)

    def testApplicationProtocolEquals(self):
        obj = self.pro.parse(self.cell.text())
        assert self.pro.equals(self.cell.text(), obj)
        assert self.pro.equals(ScientificFloat("2.798"), obj)

    def testApplicationProtocolToString(self):
        obj = self.pro.parse(self.cell)
        assert self.pro.toString(obj) == "2.798"
Exemplo n.º 48
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
Exemplo n.º 49
0
 def testIndexing(self):
     p = Parse("leader<table><tr><td>one</td><td>two</td><td>three</td></tr><tr><td>four</td></tr></table>trailer")
     self.assertEquals("one", p.at(0, 0, 0).body)
     self.assertEquals("two", p.at(0, 0, 1).body)
     self.assertEquals("three", p.at(0, 0, 2).body)
     self.assertEquals("three", p.at(0, 0, 3).body)
     self.assertEquals("three", p.at(0, 0, 4).body)
     self.assertEquals("four", p.at(0, 1, 0).body)
     self.assertEquals("four", p.at(0, 1, 1).body)
     self.assertEquals("four", p.at(0, 2, 0).body)
     self.assertEquals(1, p.size())
     self.assertEquals(2, p.parts.size())
     self.assertEquals(3, p.parts.parts.size())
     self.assertEquals("one", p.leaf().body)
     self.assertEquals("four", p.parts.last().leaf().body)
Exemplo n.º 50
0
    def ResultingHTML(self):
        table = Parse(self.OriginalHTML)
        row = table.at(0, self.Row - 1)
        cell = row.at(0, self.Column - 1)
        
        if (self.OverwriteCellBody is not None):
            cell.body = self.OverwriteCellBody
        if (self.AddToCellBody is not None):
            cell.addToBody(self.AddToCellBody)
        
        if (self.OverwriteCellTag is not None):
            cell.tag = self.OverwriteCellTag
        if (self.OverwriteEndCellTag is not None):
            cell.end = self.OverwriteEndCellTag
        if (self.AddToCellTag is not None):
            cell.addToTag(self.stripDelimiters(self.AddToCellTag))
        
        if (self.OverwriteRowTag is not None):
            row.tag = self.OverwriteRowTag
        if (self.OverwriteEndRowTag is not None):
            row.end = self.OverwriteEndRowTag
        if (self.AddToRowTag is not None):
            row.addToTag(self.stripDelimiters(self.AddToRowTag))

        if (self.OverwriteTableTag is not None):
            table.tag = self.OverwriteTableTag
        if (self.OverwriteEndTableTag is not None):
            table.end = self.OverwriteEndTableTag
        if (self.AddToTableTag is not None):
            table.addToTag(self.stripDelimiters(self.AddToTableTag))

        if (self.AddCellFollowing is not None):
            self.addParse(cell, self.AddCellFollowing, ["td"])
        if (self.RemoveFollowingCell is not None):
            self.removeParse(cell)
                
        if (self.AddRowFollowing is not None):
            self.addParse(row, self.AddRowFollowing, ["tr", "td"])
        if (self.RemoveFollowingRow is not None):
            self.removeParse(row)
        
        if (self.AddTableFollowing is not None):
            self.addParse(table, self.AddTableFollowing,
                          ["table", "tr", "td"])

        return self.GenerateOutput(table)
Exemplo n.º 51
0
 def _makeCell(self, anObject):
     aCell = Parse(tag="td")
     try:
         aCell.body = self._typeAdapter.toString(anObject, aCell)
     except Exception, e:
         self.exception(aCell, e)
Exemplo n.º 52
0
 def setUp(self):
     self.ta = tat["String"](self, "aStringVar", "String")
     self.pro = taPro.getProtocolFor(self.ta)
     self.cell = Parse(tag="td", body="spam")
     print '%s %s' % (self.id(), self.shortDescription())
Exemplo n.º 53
0
 def setUp(self):
     self.ta = tat["Float"](self, "aFloatVar", "Float", metaData={})
     self.pro = taPro.getProtocolFor(self.ta)
     self.cell = Parse(tag="td", body="3.14")
     print '%s %s' % (self.id(), self.shortDescription())
Exemplo n.º 54
0
 def setUp(self):
     self.ta = ScientificFloat
     self.pro = taPro.getProtocolFor(self.ta)
     self.cell = Parse(tag="td", body="2.798")
     print '%s %s' % (self.id(), self.shortDescription())
Exemplo n.º 55
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)
Exemplo n.º 56
0
 def testBlankCellHandlerParseWithCell(self):        
     h = BlankCellHandler()
     cell = Parse(tag="td", body="blank")
     assert h.parse(cell, None) == (OK, "")
     cell.body = "fubar"
     assert h.parse(cell, None) == (NEXT, None)
Exemplo n.º 57
0
 def shouldRaiseExceptionIfNoExit(self):
     obj = self.obj
     heads = Parse(tag="td", body='label')
     obj.bind(heads)
     assert heads.tagIsError()
     assert heads.body.find("processLabel not implemented") > 1