mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Add simplejson 3.17.0
* Needed for requests to encode byte-strings to json
This commit is contained in:
parent
42262b0bb6
commit
c2d17c285a
41 changed files with 7779 additions and 0 deletions
47
lib/simplejson/tests/test_raw_json.py
Normal file
47
lib/simplejson/tests/test_raw_json.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
import unittest
|
||||
import simplejson as json
|
||||
|
||||
dct1 = {
|
||||
'key1': 'value1'
|
||||
}
|
||||
|
||||
dct2 = {
|
||||
'key2': 'value2',
|
||||
'd1': dct1
|
||||
}
|
||||
|
||||
dct3 = {
|
||||
'key2': 'value2',
|
||||
'd1': json.dumps(dct1)
|
||||
}
|
||||
|
||||
dct4 = {
|
||||
'key2': 'value2',
|
||||
'd1': json.RawJSON(json.dumps(dct1))
|
||||
}
|
||||
|
||||
|
||||
class TestRawJson(unittest.TestCase):
|
||||
|
||||
def test_normal_str(self):
|
||||
self.assertNotEqual(json.dumps(dct2), json.dumps(dct3))
|
||||
|
||||
def test_raw_json_str(self):
|
||||
self.assertEqual(json.dumps(dct2), json.dumps(dct4))
|
||||
self.assertEqual(dct2, json.loads(json.dumps(dct4)))
|
||||
|
||||
def test_list(self):
|
||||
self.assertEqual(
|
||||
json.dumps([dct2]),
|
||||
json.dumps([json.RawJSON(json.dumps(dct2))]))
|
||||
self.assertEqual(
|
||||
[dct2],
|
||||
json.loads(json.dumps([json.RawJSON(json.dumps(dct2))])))
|
||||
|
||||
def test_direct(self):
|
||||
self.assertEqual(
|
||||
json.dumps(dct2),
|
||||
json.dumps(json.RawJSON(json.dumps(dct2))))
|
||||
self.assertEqual(
|
||||
dct2,
|
||||
json.loads(json.dumps(json.RawJSON(json.dumps(dct2)))))
|
Loading…
Add table
Add a link
Reference in a new issue