def checkExpected(self, resource): read = Out.read() expected = self.readExpected(resource) if len(expected) == 1: self.assertEqual(expected[0], read) else: for ex in expected: if ex == read: return self.assertEqual(expected[0], read) # to get a display
def runTests(self, resource, register = False): stmts = self.parseResource(resource) if register: stmts.register(self.coreContext) for decl in stmts: if not isinstance(decl, TestMethodDeclaration): continue Out.reset() Interpreter.interpretTest(self.coreContext, decl.name) expected = decl.name + " test successful" read = Out.read() self.assertEqual(read, expected)
def testSystemOutPrint(self): parser = ECleverParser(text='print(objects=value,end="")') parser._input.tokenSource.addLF = False tree = parser.python_statement() builder = EPromptoBuilder(parser) walker = ParseTreeWalker() walker.walk(builder, tree) statement = builder.getNodeValue(tree) context = Context.newGlobalContext() arg = CategoryParameter(TextType.instance, "value") arg.register(context) context.setValue("value", TextLiteral('"test"')) # StringLiteral trims enclosing quotes result = statement.interpret(context, None, None) # no module self.assertIsNone(result) self.assertEqual("test", Out.read())
def testReturnText(self): self.runResource("native/return.poc") self.assertEquals(sys.platform, Out.read())