示例#1
0
def check(self, seq, exp=None):
    global Cur, Lexer, Parser
    if exp is None: exp = seq
    intxt = unittest_extensions.readfile_utf8("data/jelparse/%s.txt" % seq)
    try:
        exptxt = unittest_extensions.readfile_utf8("data/jelparse/%s.exp" %
                                                   exp)
    except IOError:
        exptxt = intxt
    outtxt = roundtrip(Cur, intxt)
    self.assert_(8 <= len(outtxt))  # Sanity check for non-empty entry.
    msg = "\nExpected:\n%s\nGot:\n%s" % (exptxt, outtxt)
    self.assertEqual(outtxt, exptxt, msg)
示例#2
0
def loadData(filename, secsep, last=[None, None]):
    # Read test data file 'filename' caching its data and returning
    # cached data on subsequent consecutive calls with same filename.
    if last[0] != filename:
        last[1] = unittest_extensions.readfile_utf8(filename,
                                                    rmcomments=True,
                                                    secsep=secsep)
        last[0] = filename
    return last[1]
示例#3
0
def cherr(self, seq, exception, msg):
    global Cur, Lexer, Parser
    intxt = unittest_extensions.readfile_utf8("data/jelparse/%s.txt" % seq)
    jellex.lexreset(Lexer, intxt)
    _assertRaisesMsg(self, exception, msg, Parser.parse, intxt, lexer=Lexer)