File: test_fixture.py

package info (click to toggle)
python-orjson 3.11.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,116 kB
  • sloc: ansic: 11,268; python: 6,796; sh: 105; makefile: 9
file content (56 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download
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
54
55
56
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# Copyright ijl (2018-2025)

import pytest

import orjson

from .util import needs_data, read_fixture_bytes, read_fixture_str


@needs_data
class TestFixture:
    def test_twitter(self):
        """
        loads(),dumps() twitter.json
        """
        val = read_fixture_str("twitter.json.xz")
        read = orjson.loads(val)
        assert orjson.loads(orjson.dumps(read)) == read

    @needs_data
    def test_canada(self):
        """
        loads(), dumps() canada.json
        """
        val = read_fixture_str("canada.json.xz")
        read = orjson.loads(val)
        assert orjson.loads(orjson.dumps(read)) == read

    def test_citm_catalog(self):
        """
        loads(), dumps() citm_catalog.json
        """
        val = read_fixture_str("citm_catalog.json.xz")
        read = orjson.loads(val)
        assert orjson.loads(orjson.dumps(read)) == read

    def test_github(self):
        """
        loads(), dumps() github.json
        """
        val = read_fixture_str("github.json.xz")
        read = orjson.loads(val)
        assert orjson.loads(orjson.dumps(read)) == 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 pytest.raises(orjson.JSONDecodeError):
                    _ = orjson.loads(b'"' + val + b'"')