~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to python/simplejson-2.1.1/simplejson/tests/test_encode_basestring_ascii.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from unittest import TestCase
2
 
 
3
 
import simplejson.encoder
4
 
 
5
 
CASES = [
6
 
    (u'/\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\x08\x0c\n\r\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?', '"/\\\\\\"\\ucafe\\ubabe\\uab98\\ufcde\\ubcda\\uef4a\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?"'),
7
 
    (u'\u0123\u4567\u89ab\ucdef\uabcd\uef4a', '"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'),
8
 
    (u'controls', '"controls"'),
9
 
    (u'\x08\x0c\n\r\t', '"\\b\\f\\n\\r\\t"'),
10
 
    (u'{"object with 1 member":["array with 1 element"]}', '"{\\"object with 1 member\\":[\\"array with 1 element\\"]}"'),
11
 
    (u' s p a c e d ', '" s p a c e d "'),
12
 
    (u'\U0001d120', '"\\ud834\\udd20"'),
13
 
    (u'\u03b1\u03a9', '"\\u03b1\\u03a9"'),
14
 
    ('\xce\xb1\xce\xa9', '"\\u03b1\\u03a9"'),
15
 
    (u'\u03b1\u03a9', '"\\u03b1\\u03a9"'),
16
 
    ('\xce\xb1\xce\xa9', '"\\u03b1\\u03a9"'),
17
 
    (u'\u03b1\u03a9', '"\\u03b1\\u03a9"'),
18
 
    (u'\u03b1\u03a9', '"\\u03b1\\u03a9"'),
19
 
    (u"`1~!@#$%^&*()_+-={':[,]}|;.</>?", '"`1~!@#$%^&*()_+-={\':[,]}|;.</>?"'),
20
 
    (u'\x08\x0c\n\r\t', '"\\b\\f\\n\\r\\t"'),
21
 
    (u'\u0123\u4567\u89ab\ucdef\uabcd\uef4a', '"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'),
22
 
]
23
 
 
24
 
class TestEncodeBaseStringAscii(TestCase):
25
 
    def test_py_encode_basestring_ascii(self):
26
 
        self._test_encode_basestring_ascii(simplejson.encoder.py_encode_basestring_ascii)
27
 
 
28
 
    def test_c_encode_basestring_ascii(self):
29
 
        if not simplejson.encoder.c_encode_basestring_ascii:
30
 
            return
31
 
        self._test_encode_basestring_ascii(simplejson.encoder.c_encode_basestring_ascii)
32
 
 
33
 
    def _test_encode_basestring_ascii(self, encode_basestring_ascii):
34
 
        fname = encode_basestring_ascii.__name__
35
 
        for input_string, expect in CASES:
36
 
            result = encode_basestring_ascii(input_string)
37
 
            #self.assertEquals(result, expect,
38
 
            #    '{0!r} != {1!r} for {2}({3!r})'.format(
39
 
            #        result, expect, fname, input_string))
40
 
            self.assertEquals(result, expect,
41
 
                '%r != %r for %s(%r)' % (result, expect, fname, input_string))