Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
4f78c197
Commit
4f78c197
authored
Jun 19, 2013
by
Peter Baratta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow error messages with non-ascii characters to be handled correctly
Also, add a test for this behavior.
parent
9b478ff3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletions
+31
-1
CHANGELOG.rst
+2
-0
common/lib/xmodule/xmodule/capa_module.py
+1
-1
common/lib/xmodule/xmodule/tests/test_capa_module.py
+28
-0
No files found.
CHANGELOG.rst
View file @
4f78c197
...
...
@@ -42,6 +42,8 @@ setting now run entirely outside the Python sandbox.
Blades: Added tests for Video Alpha player.
Common: Have the capa module handle unicode better (especially errors)
Blades: Video Alpha bug fix for speed changing to 1.0 in Firefox.
Blades: Additional event tracking added to Video Alpha: fullscreen switch, show/hide
...
...
common/lib/xmodule/xmodule/capa_module.py
View file @
4f78c197
...
...
@@ -781,7 +781,7 @@ class CapaModule(CapaFields, XModule):
# Otherwise, display just an error message,
# without a stack trace
else
:
msg
=
"Error:
%
s"
%
str
(
inst
.
message
)
msg
=
u"Error: {msg}"
.
format
(
msg
=
inst
.
message
)
return
{
'success'
:
msg
}
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
4f78c197
# -*- coding: utf-8 -*-
"""Tests of the Capa XModule"""
#pylint: disable=C0111
#pylint: disable=R0904
...
...
@@ -520,6 +521,33 @@ class CapaModuleTest(unittest.TestCase):
# Expect that the number of attempts is NOT incremented
self
.
assertEqual
(
module
.
attempts
,
1
)
def
test_check_problem_error_nonascii
(
self
):
# Try each exception that capa_module should handle
for
exception_class
in
[
StudentInputError
,
LoncapaProblemError
,
ResponseError
]:
# Create the module
module
=
CapaFactory
.
create
(
attempts
=
1
)
# Ensure that the user is NOT staff
module
.
system
.
user_is_staff
=
False
# Simulate answering a problem that raises the exception
with
patch
(
'capa.capa_problem.LoncapaProblem.grade_answers'
)
as
mock_grade
:
mock_grade
.
side_effect
=
exception_class
(
u"ȧƈƈḗƞŧḗḓ ŧḗẋŧ ƒǿř ŧḗşŧīƞɠ"
)
get_request_dict
=
{
CapaFactory
.
input_key
():
'3.14'
}
result
=
module
.
check_problem
(
get_request_dict
)
# Expect an AJAX alert message in 'success'
expected_msg
=
u'Error: ȧƈƈḗƞŧḗḓ ŧḗẋŧ ƒǿř ŧḗşŧīƞɠ'
self
.
assertEqual
(
expected_msg
,
result
[
'success'
])
# Expect that the number of attempts is NOT incremented
self
.
assertEqual
(
module
.
attempts
,
1
)
def
test_check_problem_error_with_staff_user
(
self
):
# Try each exception that capa module should handle
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment