Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 13.58.157.5
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : test_str_subclass.py
from unittest import TestCase

import simplejson
from simplejson.compat import text_type

# Tests for issue demonstrated in https://github.com/simplejson/simplejson/issues/144
class WonkyTextSubclass(text_type):
    def __getslice__(self, start, end):
        return self.__class__('not what you wanted!')

class TestStrSubclass(TestCase):
    def test_dump_load(self):
        for s in ['', '"hello"', 'text', u'\u005c']:
            self.assertEqual(
                s,
                simplejson.loads(simplejson.dumps(WonkyTextSubclass(s))))

            self.assertEqual(
                s,
                simplejson.loads(simplejson.dumps(WonkyTextSubclass(s),
                                                  ensure_ascii=False)))
© 2025 GrazzMean-Shell