Sha256: 2dddc68672622941b65026c1819f84229c1cb90e6843aaff5b654d436e834bc7

Contents?: true

Size: 1 KB

Versions: 33

Compression:

Stored size: 1 KB

Contents

from unittest import TestCase

import simplejson as json

class TestErrors(TestCase):
    def test_string_keys_error(self):
        data = [{'a': 'A', 'b': (2, 4), 'c': 3.0, ('d',): 'D tuple'}]
        self.assertRaises(TypeError, json.dumps, data)

    def test_decode_error(self):
        err = None
        try:
            json.loads('{}\na\nb')
        except json.JSONDecodeError, e:
            err = e
        else:
            self.fail('Expected JSONDecodeError')
        self.assertEquals(err.lineno, 2)
        self.assertEquals(err.colno, 1)
        self.assertEquals(err.endlineno, 3)
        self.assertEquals(err.endcolno, 2)

    def test_scan_error(self):
        err = None
        for t in (str, unicode):
            try:
                json.loads(t('{"asdf": "'))
            except json.JSONDecodeError, e:
                err = e
            else:
                self.fail('Expected JSONDecodeError')
            self.assertEquals(err.lineno, 1)
            self.assertEquals(err.colno, 9)
        

Version data entries

33 entries across 33 versions & 5 rubygems

Version Path
pygments.rb-1.2.1 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-1.2.0 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-1.1.2 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-1.1.1 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-1.1.0 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-1.0.0 vendor/simplejson/simplejson/tests/test_errors.py
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/pygments.rb-0.6.3/vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-0.6.3 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-0.6.2 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-0.6.1 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-0.6.0 vendor/simplejson/simplejson/tests/test_errors.py
mortar-pygments.rb-0.5.7 vendor/simplejson/simplejson/tests/test_errors.py
mortar-pygments.rb-0.5.6 vendor/simplejson/simplejson/tests/test_errors.py
mortar-pygments.rb-0.5.5 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-jruby-0.5.4.2 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-jruby-0.5.4.1 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-jruby-0.5.4 vendor/simplejson/simplejson/tests/test_errors.py
gitlab-pygments.rb-0.5.4 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-0.5.4 vendor/simplejson/simplejson/tests/test_errors.py
pygments.rb-0.5.2 vendor/simplejson/simplejson/tests/test_errors.py