File: test_basic.py

package info (click to toggle)
python-msgspec 0.20.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,416 kB
  • sloc: javascript: 23,944; ansic: 20,940; python: 19,752; makefile: 26; sh: 23
file content (19 lines) | stat: -rw-r--r-- 602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pytest

from benchmarks.bench_validation import bench_msgspec


@pytest.mark.benchmark(group="roundtrip")
class TestRoundtrip:
    def test_encode(self, bench, filesystem_data, shared_data):
        data = filesystem_data()
        encoded = bench(bench_msgspec.encode, data)
        shared_data["encoded"] = encoded

    def test_decode(self, bench, shared_data):
        if shared_data["encoded"] is None:
            raise ValueError(
                "test_encode must run before test_decode to provide encoded data"
            )

        bench(bench_msgspec.decode, shared_data["encoded"])