def testSourceCode(self): cmd = os.linesep + " box([1,1,1]); " + os.linesep parser = Parser() parser.parse(cmd) resultPermanent = "".join( [elem.sourceCode for elem in parser.getStatements()]) self.assertEqual(self.strip(resultPermanent), "box([1,1,1]);") self.assertEqual(self.strip(parser.getSourceCode()), "box([1,1,1]);")
def testEquals(self): p = Parser() str = "a=1;" + os.linesep + "b=2;" + os.linesep p.parse(str) stmts = p.getStatements() self.assertEqual(len(stmts), 2) self.assertEqual(stmts[0].sourceCode, "a=1;" + os.linesep) self.assertEqual(stmts[1].sourceCode, "b=2;" + os.linesep)