mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
ecd567d8cd
--HG-- rename : testing/mozmill/simplejson-2.1.1/CHANGES.txt => other-licenses/simplejson-2.1.1/CHANGES.txt rename : testing/mozmill/simplejson-2.1.1/LICENSE.txt => other-licenses/simplejson-2.1.1/LICENSE.txt rename : testing/mozmill/simplejson-2.1.1/PKG-INFO => other-licenses/simplejson-2.1.1/PKG-INFO rename : testing/mozmill/simplejson-2.1.1/conf.py => other-licenses/simplejson-2.1.1/conf.py rename : testing/mozmill/simplejson-2.1.1/docs/_sources/index.txt => other-licenses/simplejson-2.1.1/docs/_sources/index.txt rename : testing/mozmill/simplejson-2.1.1/docs/_static/contents.png => other-licenses/simplejson-2.1.1/docs/_static/contents.png rename : testing/mozmill/simplejson-2.1.1/docs/_static/default.css => other-licenses/simplejson-2.1.1/docs/_static/default.css rename : testing/mozmill/simplejson-2.1.1/docs/_static/doctools.js => other-licenses/simplejson-2.1.1/docs/_static/doctools.js rename : testing/mozmill/simplejson-2.1.1/docs/_static/file.png => other-licenses/simplejson-2.1.1/docs/_static/file.png rename : testing/mozmill/simplejson-2.1.1/docs/_static/interface.js => other-licenses/simplejson-2.1.1/docs/_static/interface.js rename : testing/mozmill/simplejson-2.1.1/docs/_static/jquery.js => other-licenses/simplejson-2.1.1/docs/_static/jquery.js rename : testing/mozmill/simplejson-2.1.1/docs/_static/minus.png => other-licenses/simplejson-2.1.1/docs/_static/minus.png rename : testing/mozmill/simplejson-2.1.1/docs/_static/navigation.png => other-licenses/simplejson-2.1.1/docs/_static/navigation.png rename : testing/mozmill/simplejson-2.1.1/docs/_static/plus.png => other-licenses/simplejson-2.1.1/docs/_static/plus.png rename : testing/mozmill/simplejson-2.1.1/docs/_static/pygments.css => other-licenses/simplejson-2.1.1/docs/_static/pygments.css rename : testing/mozmill/simplejson-2.1.1/docs/_static/rightsidebar.css => other-licenses/simplejson-2.1.1/docs/_static/rightsidebar.css rename : testing/mozmill/simplejson-2.1.1/docs/_static/searchtools.js => other-licenses/simplejson-2.1.1/docs/_static/searchtools.js rename : testing/mozmill/simplejson-2.1.1/docs/_static/sphinxdoc.css => other-licenses/simplejson-2.1.1/docs/_static/sphinxdoc.css rename : testing/mozmill/simplejson-2.1.1/docs/_static/stickysidebar.css => other-licenses/simplejson-2.1.1/docs/_static/stickysidebar.css rename : testing/mozmill/simplejson-2.1.1/docs/_static/traditional.css => other-licenses/simplejson-2.1.1/docs/_static/traditional.css rename : testing/mozmill/simplejson-2.1.1/docs/genindex.html => other-licenses/simplejson-2.1.1/docs/genindex.html rename : testing/mozmill/simplejson-2.1.1/docs/index.html => other-licenses/simplejson-2.1.1/docs/index.html rename : testing/mozmill/simplejson-2.1.1/docs/objects.inv => other-licenses/simplejson-2.1.1/docs/objects.inv rename : testing/mozmill/simplejson-2.1.1/docs/search.html => other-licenses/simplejson-2.1.1/docs/search.html rename : testing/mozmill/simplejson-2.1.1/docs/searchindex.js => other-licenses/simplejson-2.1.1/docs/searchindex.js rename : testing/mozmill/simplejson-2.1.1/docs/searchindex.json => other-licenses/simplejson-2.1.1/docs/searchindex.json rename : testing/mozmill/simplejson-2.1.1/ez_setup.py => other-licenses/simplejson-2.1.1/ez_setup.py rename : testing/mozmill/simplejson-2.1.1/index.rst => other-licenses/simplejson-2.1.1/index.rst rename : testing/mozmill/simplejson-2.1.1/scripts/make_docs.py => other-licenses/simplejson-2.1.1/scripts/make_docs.py rename : testing/mozmill/simplejson-2.1.1/setup.cfg => other-licenses/simplejson-2.1.1/setup.cfg rename : testing/mozmill/simplejson-2.1.1/setup.py => other-licenses/simplejson-2.1.1/setup.py rename : testing/mozmill/simplejson-2.1.1/simplejson/__init__.py => other-licenses/simplejson-2.1.1/simplejson/__init__.py rename : testing/mozmill/simplejson-2.1.1/simplejson/_speedups.c => other-licenses/simplejson-2.1.1/simplejson/_speedups.c rename : testing/mozmill/simplejson-2.1.1/simplejson/decoder.py => other-licenses/simplejson-2.1.1/simplejson/decoder.py rename : testing/mozmill/simplejson-2.1.1/simplejson/encoder.py => other-licenses/simplejson-2.1.1/simplejson/encoder.py rename : testing/mozmill/simplejson-2.1.1/simplejson/ordered_dict.py => other-licenses/simplejson-2.1.1/simplejson/ordered_dict.py rename : testing/mozmill/simplejson-2.1.1/simplejson/scanner.py => other-licenses/simplejson-2.1.1/simplejson/scanner.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/__init__.py => other-licenses/simplejson-2.1.1/simplejson/tests/__init__.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_check_circular.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_check_circular.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_decimal.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_decimal.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_decode.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_decode.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_default.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_default.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_dump.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_dump.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_encode_basestring_ascii.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_encode_basestring_ascii.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_encode_for_html.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_encode_for_html.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_fail.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_fail.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_float.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_float.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_indent.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_indent.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_pass1.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_pass1.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_pass2.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_pass2.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_pass3.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_pass3.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_recursion.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_recursion.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_scanstring.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_scanstring.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_separators.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_separators.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_speedups.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_speedups.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tests/test_unicode.py => other-licenses/simplejson-2.1.1/simplejson/tests/test_unicode.py rename : testing/mozmill/simplejson-2.1.1/simplejson/tool.py => other-licenses/simplejson-2.1.1/simplejson/tool.py rename : testing/mozmill/virtualenv/MANIFEST.in => other-licenses/virtualenv/MANIFEST.in rename : testing/mozmill/virtualenv/PKG-INFO => other-licenses/virtualenv/PKG-INFO rename : testing/mozmill/virtualenv/docs/_build/_sources/index.txt => other-licenses/virtualenv/docs/_build/_sources/index.txt rename : testing/mozmill/virtualenv/docs/_build/_sources/license.txt => other-licenses/virtualenv/docs/_build/_sources/license.txt rename : testing/mozmill/virtualenv/docs/_build/_sources/news.txt => other-licenses/virtualenv/docs/_build/_sources/news.txt rename : testing/mozmill/virtualenv/docs/index.txt => other-licenses/virtualenv/docs/index.txt rename : testing/mozmill/virtualenv/docs/license.txt => other-licenses/virtualenv/docs/license.txt rename : testing/mozmill/virtualenv/docs/news.txt => other-licenses/virtualenv/docs/news.txt rename : testing/mozmill/virtualenv/scripts/virtualenv => other-licenses/virtualenv/scripts/virtualenv rename : testing/mozmill/virtualenv/setup.cfg => other-licenses/virtualenv/setup.cfg rename : testing/mozmill/virtualenv/setup.py => other-licenses/virtualenv/setup.py rename : testing/mozmill/virtualenv/virtualenv.py => other-licenses/virtualenv/virtualenv.py rename : testing/mozmill/virtualenv/virtualenv_support/__init__.py => other-licenses/virtualenv/virtualenv_support/__init__.py rename : testing/mozmill/virtualenv/virtualenv_support/distribute-0.6.8.tar.gz => other-licenses/virtualenv/virtualenv_support/distribute-0.6.8.tar.gz rename : testing/mozmill/virtualenv/virtualenv_support/pip-0.7.1.tar.gz => other-licenses/virtualenv/virtualenv_support/pip-0.7.1.tar.gz rename : testing/mozmill/virtualenv/virtualenv_support/setuptools-0.6c11-py2.4.egg => other-licenses/virtualenv/virtualenv_support/setuptools-0.6c11-py2.4.egg rename : testing/mozmill/virtualenv/virtualenv_support/setuptools-0.6c11-py2.5.egg => other-licenses/virtualenv/virtualenv_support/setuptools-0.6c11-py2.5.egg rename : testing/mozmill/virtualenv/virtualenv_support/setuptools-0.6c11-py2.6.egg => other-licenses/virtualenv/virtualenv_support/setuptools-0.6c11-py2.6.egg
100 lines
4.1 KiB
Python
100 lines
4.1 KiB
Python
from unittest import TestCase
|
|
|
|
import simplejson as json
|
|
|
|
class TestUnicode(TestCase):
|
|
def test_encoding1(self):
|
|
encoder = json.JSONEncoder(encoding='utf-8')
|
|
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
|
|
s = u.encode('utf-8')
|
|
ju = encoder.encode(u)
|
|
js = encoder.encode(s)
|
|
self.assertEquals(ju, js)
|
|
|
|
def test_encoding2(self):
|
|
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
|
|
s = u.encode('utf-8')
|
|
ju = json.dumps(u, encoding='utf-8')
|
|
js = json.dumps(s, encoding='utf-8')
|
|
self.assertEquals(ju, js)
|
|
|
|
def test_encoding3(self):
|
|
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
|
|
j = json.dumps(u)
|
|
self.assertEquals(j, '"\\u03b1\\u03a9"')
|
|
|
|
def test_encoding4(self):
|
|
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
|
|
j = json.dumps([u])
|
|
self.assertEquals(j, '["\\u03b1\\u03a9"]')
|
|
|
|
def test_encoding5(self):
|
|
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
|
|
j = json.dumps(u, ensure_ascii=False)
|
|
self.assertEquals(j, u'"' + u + u'"')
|
|
|
|
def test_encoding6(self):
|
|
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
|
|
j = json.dumps([u], ensure_ascii=False)
|
|
self.assertEquals(j, u'["' + u + u'"]')
|
|
|
|
def test_big_unicode_encode(self):
|
|
u = u'\U0001d120'
|
|
self.assertEquals(json.dumps(u), '"\\ud834\\udd20"')
|
|
self.assertEquals(json.dumps(u, ensure_ascii=False), u'"\U0001d120"')
|
|
|
|
def test_big_unicode_decode(self):
|
|
u = u'z\U0001d120x'
|
|
self.assertEquals(json.loads('"' + u + '"'), u)
|
|
self.assertEquals(json.loads('"z\\ud834\\udd20x"'), u)
|
|
|
|
def test_unicode_decode(self):
|
|
for i in range(0, 0xd7ff):
|
|
u = unichr(i)
|
|
#s = '"\\u{0:04x}"'.format(i)
|
|
s = '"\\u%04x"' % (i,)
|
|
self.assertEquals(json.loads(s), u)
|
|
|
|
def test_object_pairs_hook_with_unicode(self):
|
|
s = u'{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
|
|
p = [(u"xkd", 1), (u"kcw", 2), (u"art", 3), (u"hxm", 4),
|
|
(u"qrt", 5), (u"pad", 6), (u"hoy", 7)]
|
|
self.assertEqual(json.loads(s), eval(s))
|
|
self.assertEqual(json.loads(s, object_pairs_hook=lambda x: x), p)
|
|
od = json.loads(s, object_pairs_hook=json.OrderedDict)
|
|
self.assertEqual(od, json.OrderedDict(p))
|
|
self.assertEqual(type(od), json.OrderedDict)
|
|
# the object_pairs_hook takes priority over the object_hook
|
|
self.assertEqual(json.loads(s,
|
|
object_pairs_hook=json.OrderedDict,
|
|
object_hook=lambda x: None),
|
|
json.OrderedDict(p))
|
|
|
|
|
|
def test_default_encoding(self):
|
|
self.assertEquals(json.loads(u'{"a": "\xe9"}'.encode('utf-8')),
|
|
{'a': u'\xe9'})
|
|
|
|
def test_unicode_preservation(self):
|
|
self.assertEquals(type(json.loads(u'""')), unicode)
|
|
self.assertEquals(type(json.loads(u'"a"')), unicode)
|
|
self.assertEquals(type(json.loads(u'["a"]')[0]), unicode)
|
|
|
|
def test_ensure_ascii_false_returns_unicode(self):
|
|
# http://code.google.com/p/simplejson/issues/detail?id=48
|
|
self.assertEquals(type(json.dumps([], ensure_ascii=False)), unicode)
|
|
self.assertEquals(type(json.dumps(0, ensure_ascii=False)), unicode)
|
|
self.assertEquals(type(json.dumps({}, ensure_ascii=False)), unicode)
|
|
self.assertEquals(type(json.dumps("", ensure_ascii=False)), unicode)
|
|
|
|
def test_ensure_ascii_false_bytestring_encoding(self):
|
|
# http://code.google.com/p/simplejson/issues/detail?id=48
|
|
doc1 = {u'quux': 'Arr\xc3\xaat sur images'}
|
|
doc2 = {u'quux': u'Arr\xeat sur images'}
|
|
doc_ascii = '{"quux": "Arr\\u00eat sur images"}'
|
|
doc_unicode = u'{"quux": "Arr\xeat sur images"}'
|
|
self.assertEquals(json.dumps(doc1), doc_ascii)
|
|
self.assertEquals(json.dumps(doc2), doc_ascii)
|
|
self.assertEquals(json.dumps(doc1, ensure_ascii=False), doc_unicode)
|
|
self.assertEquals(json.dumps(doc2, ensure_ascii=False), doc_unicode)
|