File: test_encode_basestring_ascii.py

package info (click to toggle)
python-sdjson 0.5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: python: 1,566; makefile: 6; sh: 6
file content (18 lines) | stat: -rw-r--r-- 535 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# stdlib
from collections import OrderedDict

# this package
import sdjson


def test_ordered_dict() -> None:
	# See issue 6105
	items = [("one", 1), ("two", 2), ("three", 3), ("four", 4), ("five", 5)]
	s = sdjson.dumps(OrderedDict(items))
	assert s == '{"one": 1, "two": 2, "three": 3, "four": 4, "five": 5}'


def test_sorted_dict() -> None:
	items = [("one", 1), ("two", 2), ("three", 3), ("four", 4), ("five", 5)]
	s = sdjson.dumps(dict(items), sort_keys=True)
	assert s == '{"five": 5, "four": 4, "one": 1, "three": 3, "two": 2}'