File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: (Apache-2.0 OR MIT)
2+
3+ import unittest
4+
5+ import orjson
6+
7+
8+ class DictTests (unittest .TestCase ):
9+ def test_dict_pop_replace_first (self ):
10+ """Test pop and replace a first key in a dict with other keys."""
11+ data = {"id" : "any" , "other" : "any" }
12+ data .pop ("id" )
13+ data ["id" ] = "new"
14+ self .assertEqual (orjson .dumps (data ), b'{"other":"any","id":"new"}' )
15+
16+ def test_dict_pop_replace_last (self ):
17+ """Test pop and replace a last key in a dict with other keys."""
18+ data = {"other" : "any" , "id" : "any" }
19+ data .pop ("id" )
20+ data ["id" ] = "new"
21+ self .assertEqual (orjson .dumps (data ), b'{"other":"any","id":"new"}' )
22+
23+ def test_dict_pop (self ):
24+ """Test pop and replace a key in a dict with no other keys."""
25+ data = {"id" : "any" }
26+ data .pop ("id" )
27+ data ["id" ] = "new"
28+ self .assertEqual (orjson .dumps (data ), b'{"id":"new"}' )
You can’t perform that action at this time.
0 commit comments