forked from ijl/orjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_dict.py
More file actions
28 lines (22 loc) · 934 Bytes
/
Copy pathtest_dict.py
File metadata and controls
28 lines (22 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import unittest
import orjson
class DictTests(unittest.TestCase):
def test_dict_pop_replace_first(self):
"""Test pop and replace a first key in a dict with other keys."""
data = {"id": "any", "other": "any"}
data.pop("id")
data["id"] = "new"
self.assertEqual(orjson.dumps(data), b'{"other":"any","id":"new"}')
def test_dict_pop_replace_last(self):
"""Test pop and replace a last key in a dict with other keys."""
data = {"other": "any", "id": "any"}
data.pop("id")
data["id"] = "new"
self.assertEqual(orjson.dumps(data), b'{"other":"any","id":"new"}')
def test_dict_pop(self):
"""Test pop and replace a key in a dict with no other keys."""
data = {"id": "any"}
data.pop("id")
data["id"] = "new"
self.assertEqual(orjson.dumps(data), b'{"id":"new"}')