From 5e64af5a14fa6537b0e20db9931f27e9bc5e9c82 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Thu, 3 Jun 2021 03:32:21 +0300 Subject: Handles Code Questions With No Tests Adds a check to handle code questions with no test suites. Signed-off-by: Hassan Abouelela --- backend/routes/forms/unittesting.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/routes/forms/unittesting.py b/backend/routes/forms/unittesting.py index c23ff48..bd14edf 100644 --- a/backend/routes/forms/unittesting.py +++ b/backend/routes/forms/unittesting.py @@ -65,7 +65,19 @@ async def execute_unittest(form_response: FormResponse, form: Form) -> list[Unit unittest_results = [] for index, question in enumerate(form.questions): - if question.type == "code" and "unittests" in question.data: + if question.type == "code": + + # Exit early if the suite doesn't have any tests + if question.data["unittests"] is None: + unittest_results.append(UnittestResult( + question_id=question.id, + question_index=index, + return_code=0, + passed=True, + result="" + )) + continue + passed = False # Tests starting with an hashtag should have censored names. -- cgit v1.2.3