Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
codejail
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
codejail
Commits
7dbdf671
Commit
7dbdf671
authored
May 06, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style issue fixes
parent
318f977c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
codejail/tests/test_json_safe.py
+16
-5
No files found.
codejail/tests/test_json_safe.py
View file @
7dbdf671
""" Test JSON serialization straw """
"""
Test JSON serialization straw
"""
import
unittest
from
codejail.safe_exec
import
json_safe
class
JsonSafeTest
(
unittest
.
TestCase
):
""" Test JSON serialization straw """
"""
Test JSON serialization straw
"""
# Unicode surrogate values
SURROGATE_RANGE
=
range
(
55296
,
57344
)
def
test_unicode
(
self
):
""" Test that json_safe() handles non-surrogate unicode values """
"""
Test that json_safe() handles non-surrogate unicode values
"""
# Try a few non-ascii UTF-16 characters
for
unicode_char
in
[
unichr
(
512
),
unichr
(
2
**
8
-
1
),
unichr
(
2
**
16
-
1
)]:
...
...
@@ -24,7 +31,9 @@ class JsonSafeTest(unittest.TestCase):
self
.
assertEqual
(
result
.
get
(
unicode_char
,
None
),
'test'
)
def
test_surrogate_unicode_values
(
self
):
""" Test that json_safe() excludes surrogate unicode values """
"""
Test that json_safe() excludes surrogate unicode values
"""
# Try surrogate unicode values
for
code
in
self
.
SURROGATE_RANGE
:
...
...
@@ -36,7 +45,9 @@ class JsonSafeTest(unittest.TestCase):
self
.
assertFalse
(
'test'
in
result
)
def
test_surrogate_unicode_keys
(
self
):
""" Test that json_safe() excludes surrogate unicode keys """
"""
Test that json_safe() excludes surrogate unicode keys
"""
# Try surrogate unicode values
for
code
in
self
.
SURROGATE_RANGE
:
...
...
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