def testWrongTwo(self): with self.assertRaisesRegexp(Exception, "expects 2 args, got 0."): annotator.MatchAnnotation('@@@STEP_LOG_LINE@@@', self.c) with self.assertRaisesRegexp(Exception, "expects 2 args, got 1."): annotator.MatchAnnotation('@@@STEP_LOG_LINE @@@', self.c) with self.assertRaisesRegexp(Exception, "expects 2 args, got 1."): annotator.MatchAnnotation('@@@STEP_LOG_LINE@foo@@@', self.c)
def testNonAnnotated(self): annotator.MatchAnnotation('@not really an annotation', self.c) annotator.MatchAnnotation('@@@also not really an annotation@@', self.c) annotator.MatchAnnotation('#@@@totally not an annotation@@@', self.c) annotator.MatchAnnotation('###clearly not an annotation###', self.c) annotator.MatchAnnotation('@@@', self.c) self.assertEqual(self.c.called, [])
def testAlias(self): annotator.MatchAnnotation('@@@BUILD_WARNINGS@@@', self.c) annotator.MatchAnnotation('@@@link@foo@bar@trashcan@@@', self.c) self.assertEqual(self.c.called, [ ('STEP_WARNINGS', []), ('STEP_LINK', ['foo', 'bar@trashcan']), ])
def testOneAnnotated(self): annotator.MatchAnnotation('@@@SEED_STEP@@@@', self.c) annotator.MatchAnnotation('@@@SEED_STEP@foo bar@@@', self.c) annotator.MatchAnnotation('@@@SEED_STEP bat fur@@@', self.c) annotator.MatchAnnotation('@@@SEED_STEP@ doom cake@@@', self.c) annotator.MatchAnnotation('@@@SEED_STEP sooper p@nts@@@', self.c) self.assertEqual(self.c.called, [ ('SEED_STEP', ['']), ('SEED_STEP', ['foo bar']), ('SEED_STEP', ['bat fur']), ('SEED_STEP', [' doom cake']), ('SEED_STEP', [' sooper p@nts']), ])
def testTrigger(self): annotator.MatchAnnotation( '@@@STEP_TRIGGER {"builderNames": ["myBuilder"]}@@@', self.c) annotator.MatchAnnotation(( '@@@STEP_TRIGGER {"builderNames": ["myBuilder"], "set_properties":' '{"answer": 42}}@@@'), self.c) self.assertEqual(self.c.called, [ ('STEP_TRIGGER', [{ u'builderNames': [u'myBuilder'] }]), ('STEP_TRIGGER', [{ u'builderNames': [u'myBuilder'], u'set_properties': { u'answer': 42 }, }]), ])
def testTwoAnnotated(self): annotator.MatchAnnotation('@@@STEP_LOG_LINE@foo bar@ awesome line!@@@', self.c) annotator.MatchAnnotation('@@@STEP_LOG_LINE bat fur@ cool line.@@@', self.c) annotator.MatchAnnotation('@@@STEP_LOG_LINE@ doom cake@ok@line :/@@@', self.c) annotator.MatchAnnotation('@@@STEP_LOG_LINE sooper pants@ pants@@@', self.c) annotator.MatchAnnotation('@@@STEP_LOG_LINE @@@@', self.c) self.assertEqual(self.c.called, [ ('STEP_LOG_LINE', ['foo bar', ' awesome line!']), ('STEP_LOG_LINE', ['bat fur', ' cool line.']), ('STEP_LOG_LINE', [' doom cake', 'ok@line :/']), ('STEP_LOG_LINE', [' sooper pants', ' pants']), ('STEP_LOG_LINE', ['', '']), ])
def testMissingImpl(self): with self.assertRaisesRegexp(Exception, "does not implement"): annotator.MatchAnnotation('@@@SEED_STEP_TEXT@thingy@i like pie@@@', self.c)
def testBadAnnotation(self): with self.assertRaisesRegexp(Exception, "Unrecognized annotator"): annotator.MatchAnnotation('@@@SOME_OTHER_METHOD@@@', self.c)
def testWrongImpl(self): with self.assertRaisesRegexp(TypeError, "takes exactly 1 argument"): annotator.MatchAnnotation('@@@STEP_CURSOR@p-pow!@@@', self.c)
def testWrongZero(self): with self.assertRaisesRegexp(Exception, "expects 1 args, got 0."): annotator.MatchAnnotation('@@@SEED_STEP@@@', self.c)
def testZeroCruft(self): with self.assertRaisesRegexp(Exception, "cruft"): annotator.MatchAnnotation('@@@STEP_WARNINGS flazoo@@@', self.c)
def testZeroAnnotatedCruft(self): with self.assertRaisesRegexp(Exception, 'cruft "@"'): annotator.MatchAnnotation('@@@STEP_WARNINGS@@@@', self.c) with self.assertRaisesRegexp(Exception, 'cruft " "'): annotator.MatchAnnotation('@@@STEP_WARNINGS @@@', self.c)
def testZeroAnnotated(self): annotator.MatchAnnotation('@@@STEP_WARNINGS@@@', self.c) self.assertEqual(self.c.called, [ ('STEP_WARNINGS', []), ])
def handleOutputLine(self, line): """This is called once with each line of the test log.""" # Handle initial setup here, as step_status might not exist yet at init. self.initialSection() annotator.MatchAnnotation(line.rstrip(), self)