Skip to content

Commit 29cb79c

Browse files
feat(numericalInput): fix tests in inputtypes
1 parent bed9700 commit 29cb79c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

xmodule/capa/inputtypes.py

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

xmodule/capa_block.py

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

0 commit comments

Comments
 (0)