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)
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]
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)