diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index b55744baefd0909eb9d438dfb505b37bbb0a16e0..51a18ba88652df40d78234be94e282d04d7e49fb 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -189,7 +189,10 @@ class LoncapaResponse(object): raise LoncapaProblemError(msg) for prop in self.required_attributes: - if not xml.get(prop): + prop_value = xml.get(prop) + if prop_value: # Stripping off the empty strings + prop_value = prop_value.strip() + if not prop_value: msg = "Error in problem specification: %s missing required attribute %s" % ( unicode(self), prop) msg += "\nSee XML source line %s" % getattr( diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index adbbe88f8c0d71428b3d534f488b0290d9934723..ec4ba13b6efa8a886a4ef546dea14e06a7078c2f 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -946,12 +946,12 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring hint = correct_map.get_hint('1_2_1') self.assertEqual(hint, self._get_random_number_result(problem.seed)) - def test_empty_answer_graded_as_incorrect(self): + def test_empty_answer_problem_creation_not_allowed(self): """ - Tests that problem should be graded incorrect if blank space is chosen as answer + Tests that empty answer string is not allowed to create a problem """ - problem = self.build_problem(answer=" ", case_sensitive=False, regexp=True) - self.assert_grade(problem, u" ", "incorrect") + with self.assertRaises(LoncapaProblemError): + self.build_problem(answer=" ", case_sensitive=False, regexp=True) class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring