forked from ijl/orjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_append_newline.py
More file actions
51 lines (42 loc) · 1.45 KB
/
Copy pathtest_append_newline.py
File metadata and controls
51 lines (42 loc) · 1.45 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import unittest
import orjson
from .util import read_fixture_obj
class AppendNewlineTests(unittest.TestCase):
def test_dumps_newline(self):
"""
dumps() OPT_APPEND_NEWLINE
"""
self.assertEqual(orjson.dumps([], option=orjson.OPT_APPEND_NEWLINE), b"[]\n")
def test_twitter_newline(self):
"""
loads(),dumps() twitter.json OPT_APPEND_NEWLINE
"""
val = read_fixture_obj("twitter.json.xz")
self.assertEqual(
orjson.loads(orjson.dumps(val, option=orjson.OPT_APPEND_NEWLINE)), val
)
def test_canada(self):
"""
loads(), dumps() canada.json OPT_APPEND_NEWLINE
"""
val = read_fixture_obj("canada.json.xz")
self.assertEqual(
orjson.loads(orjson.dumps(val, option=orjson.OPT_APPEND_NEWLINE)), val
)
def test_citm_catalog_newline(self):
"""
loads(), dumps() citm_catalog.json OPT_APPEND_NEWLINE
"""
val = read_fixture_obj("citm_catalog.json.xz")
self.assertEqual(
orjson.loads(orjson.dumps(val, option=orjson.OPT_APPEND_NEWLINE)), val
)
def test_github_newline(self):
"""
loads(), dumps() github.json OPT_APPEND_NEWLINE
"""
val = read_fixture_obj("github.json.xz")
self.assertEqual(
orjson.loads(orjson.dumps(val, option=orjson.OPT_APPEND_NEWLINE)), val
)