aboutsummaryrefslogtreecommitdiffstats
path: root/backend
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-06-03 03:32:21 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-06-03 03:50:26 +0300
commit5e64af5a14fa6537b0e20db9931f27e9bc5e9c82 (patch)
treea34a4c4a175a7ce3a7313968596ffa0d736c0430 /backend
parentClarify Validator Semantics (diff)
Handles Code Questions With No Tests
Adds a check to handle code questions with no test suites. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'backend')
-rw-r--r--backend/routes/forms/unittesting.py14
1 files changed, 13 insertions, 1 deletions
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.