forked from ijl/orjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fixture.py
More file actions
53 lines (43 loc) · 1.37 KB
/
Copy pathtest_fixture.py
File metadata and controls
53 lines (43 loc) · 1.37 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
52
53
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import unittest
import orjson
from .util import read_fixture_bytes, read_fixture_str
class FixtureTests(unittest.TestCase):
def test_twitter(self):
"""
loads(),dumps() twitter.json
"""
val = read_fixture_str("twitter.json.xz")
read = orjson.loads(val)
orjson.dumps(read)
def test_canada(self):
"""
loads(), dumps() canada.json
"""
val = read_fixture_str("canada.json.xz")
read = orjson.loads(val)
orjson.dumps(read)
def test_citm_catalog(self):
"""
loads(), dumps() citm_catalog.json
"""
val = read_fixture_str("citm_catalog.json.xz")
read = orjson.loads(val)
orjson.dumps(read)
def test_github(self):
"""
loads(), dumps() github.json
"""
val = read_fixture_str("github.json.xz")
read = orjson.loads(val)
orjson.dumps(read)
def test_blns(self):
"""
loads() blns.json JSONDecodeError
https://github.com/minimaxir/big-list-of-naughty-strings
"""
val = read_fixture_bytes("blns.txt.xz")
for line in val.split(b"\n"):
if line and not line.startswith(b"#"):
with self.assertRaises(orjson.JSONDecodeError):
_ = orjson.loads(b'"' + val + b'"')