tests: simplify tests for my.core.serialize a bit and simplify tox file

This commit is contained in:
Dima Gerasimov 2024-08-06 23:09:56 +01:00 committed by karlicoss
parent 3aebc573e8
commit fb8e9909a4
6 changed files with 109 additions and 88 deletions

View file

@ -1 +0,0 @@
from my.core.serialize import *

View file

@ -1,23 +0,0 @@
'''
This file should only run when simplejson is installed,
but orjson is not installed to check compatibility
'''
# none of these should fail
import json
import simplejson
import pytest
from my.core.serialize import dumps, _A
def test_simplejson_fallback() -> None:
# should fail to import
with pytest.raises(ModuleNotFoundError):
import orjson
# simplejson should serialize namedtuple properly
res: str = dumps(_A(x=1, y=2.0))
assert json.loads(res) == {"x": 1, "y": 2.0}