tests: simplify tests for my.core.serialize a bit and simplify tox file
This commit is contained in:
parent
3aebc573e8
commit
fb8e9909a4
6 changed files with 109 additions and 88 deletions
|
@ -1 +0,0 @@
|
|||
from my.core.serialize import *
|
|
@ -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}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue