def test_ReadAnswersCorrupted(self): t = temp_file_with_contents(['this is not json']) with self.assertRaises(SystemExit) as context: evaluator.read_answers(t) os.remove(t) self.assertEqual(context.exception.code, evaluator.EXIT_STATUS_ANSWERS_MALFORMED)
def test_ReadAnswersRepeated(self): t = temp_file_with_contents([ '{"id": "P1", "gold_label": "E"}\n', '{"id": "P1", "gold_label": "N"}\n', ]) with self.assertRaises(SystemExit) as context: evaluator.read_answers(t) os.remove(t) self.assertEqual(context.exception.code, evaluator.EXIT_STATUS_ANSWERS_MALFORMED)
def test_ReadAnswers(self): t = temp_file_with_contents([ '{"id": "P1", "gold_label": "E"}\n', '{"id": "P2", "gold_label": "N"}\n', '{"id": "P3", "gold_label": "N"}\n', ]) answers = evaluator.read_answers(t) os.remove(t) self.assertEqual(answers, {"P1": "E", "P2": "N", "P3": "N"})
def test_ReadAnswers(self): t = temp_file_with_contents([ '{"id": "Q1", "answerKey": "A"}\n', '{"id": "Q2", "answerKey": "B"}\n', '{"id": "Q3", "answerKey": "C"}\n', ]) answers = evaluator.read_answers(t) os.remove(t) self.assertEqual(answers, {"Q1": "A", "Q2": "B", "Q3": "C"})