Skip to content

Commit 64f0512

Browse files
feat(numericalInput): fix tests in inputtypes
1 parent 89d5424 commit 64f0512

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

xmodule/capa/inputtypes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,9 @@ def preview_formcalc(self, get):
13121312
# if formula is invalid return formula
13131313
if not numeric_result["is_valid"]:
13141314
result["formula"] = formula
1315+
except pyparsing.ParseException:
1316+
result['error'] = _("Sorry, couldn't parse formula")
1317+
result['formula'] = formula
13151318
except Exception: # lint-amnesty, pylint: disable=broad-except
13161319
log.warning("Error while previewing formula", exc_info=True)
13171320
result["error"] = _("Error while rendering preview")

xmodule/capa_block.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2407,7 +2407,8 @@ def preview_numeric_input(cls, formula):
24072407
result["error"] = "Sorry, couldn't parse formula"
24082408
result['is_valid'] = False
24092409
return result
2410-
except (ValueError, TypeError):
2410+
2411+
except Exception: # pylint: disable=broad-exception-caught
24112412
log.warning("Error while previewing formula", exc_info=True)
24122413
result['error'] = "Error while rendering preview"
24132414
result['is_valid'] = False

0 commit comments

Comments
 (0)