Example #1
0
 def assertTestPass(self, test_rec):
     self.assertEqual(
         test_record.Outcome.PASS,
         test_rec.outcome,
         msg='\n\n{}'.format(
             text.StringFromTestRecord(
                 test_rec,
                 only_failures=True,
                 maximum_num_measurements=_MAXIMUM_NUM_MEASUREMENTS_PER_PHASE
             )))
Example #2
0
 def testStringFromTestRecord_SuccessfullyConvertsTestOnlyFailurePhase(
         self):
     record = self.execute_phase_or_test(
         openhtf.Test(PhaseThatSucceeds, PhaseWithFailure))
     output = text.StringFromTestRecord(record, only_failures=True)
     self.assertEqual(
         output, 'Test finished with a FAIL :(\n'
         'Phase PhaseWithFailure\n'
         '+ Outcome: FAIL Result: CONTINUE\n'
         '| text_measurement_a failed because intentionally wrong measurement '
         'failed these checks: ["\'x\' matches /^a$/"]\n'
         'Test finished with a FAIL :(')
     self.assertNotIn(text._BRIGHT_RED_STYLE, output)
Example #3
0
 def testStringFromTestRecord_SuccessfullyConvertsTestErrorPhase(self):
     record = self.execute_phase_or_test(openhtf.Test(PhaseWithError))
     self.assertEqual(
         text.StringFromTestRecord(record), 'Test encountered an ERROR!!!\n'
         'Phase trigger_phase\n'
         '+ Outcome: PASS Result: CONTINUE\n'
         'Phase PhaseWithError\n'
         '+ Outcome: ERROR Result: Exception\n'
         '| text_measurement_a was not set\n'
         '| text_measurement_b was not set\n'
         'The test thinks this may be the reason:\n'
         'Exception: Intentional exception from test case.\n'
         'Test encountered an ERROR!!!')
Example #4
0
 def testStringFromTestRecord_SuccessfullyConvertsTestRecordSinglePassPhase(
         self):
     record = self.execute_phase_or_test(openhtf.Test(PhaseThatSucceeds))
     self.assertEqual(
         text.StringFromTestRecord(record), 'Test finished with a PASS!\n'
         'Woohoo!\n'
         'Phase trigger_phase\n'
         '+ Outcome: PASS Result: CONTINUE\n'
         'Phase PhaseThatSucceeds\n'
         '+ Outcome: PASS Result: CONTINUE\n'
         '| text_measurement_a: a\n'
         '| text_measurement_b: b\n'
         '| attachment: attachment_a.txt (mimetype=text/plain)\n'
         '| attachment: attachment_b.json (mimetype=application/json)\n'
         'Test finished with a PASS!')
Example #5
0
 def testStringFromTestRecord_SuccessfullyConvertsTestFailureMultiplePhases(
         self):
     record = self.execute_phase_or_test(
         openhtf.Test(PhaseThatSucceeds, PhaseWithFailure))
     self.assertEqual(
         text.StringFromTestRecord(record), 'Test finished with a FAIL :(\n'
         'Phase trigger_phase\n'
         '+ Outcome: PASS Result: CONTINUE\n'
         'Phase PhaseThatSucceeds\n'
         '+ Outcome: PASS Result: CONTINUE\n'
         '| text_measurement_a: a\n'
         '| text_measurement_b: b\n'
         '| attachment: attachment_a.txt (mimetype=text/plain)\n'
         '| attachment: attachment_b.json (mimetype=application/json)\n'
         'Phase PhaseWithFailure\n'
         '+ Outcome: FAIL Result: CONTINUE\n'
         '| text_measurement_a failed because intentionally wrong measurement '
         'failed these checks: ["\'x\' matches /^a$/"]\n'
         '| text_measurement_b was not set\n'
         '| text_measurement_c: c\n'
         'Test finished with a FAIL :(')
Example #6
0
 def testStringFromTestRecord_SuccessfullyConvertsTestFailurePhaseColored(
         self):
     record = self.execute_phase_or_test(openhtf.Test(PhaseWithFailure))
     self.assertEqual(
         text.StringFromTestRecord(record, colorize_text=True).count(_RED),
         5)