Fixed imports
This commit is contained in:
parent
b6537a50ae
commit
723cc40221
@ -1,4 +1,8 @@
|
||||
from json import JSONDecodeError, dumps
|
||||
try:
|
||||
from ujson import JSONDecodeError, dumps
|
||||
except ImportError:
|
||||
from json import dumps, JSONDecodeError
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Union
|
||||
|
||||
@ -29,13 +33,13 @@ async def test_json_read_valid(path: Union[str, Path], expected: Any):
|
||||
@pytest.mark.parametrize(
|
||||
"path, expected",
|
||||
[
|
||||
("tests/data/invalid.json", pytest.raises(JSONDecodeError)),
|
||||
("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)),
|
||||
("tests/data/invalid.json", JSONDecodeError),
|
||||
("tests/data/nonexistent.json", FileNotFoundError),
|
||||
],
|
||||
)
|
||||
async def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
||||
with expected:
|
||||
assert await json_read(path) == expected
|
||||
with pytest.raises(expected):
|
||||
await json_read(path)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
@ -1,4 +1,8 @@
|
||||
from json import JSONDecodeError, dumps
|
||||
try:
|
||||
from ujson import JSONDecodeError, dumps
|
||||
except ImportError:
|
||||
from json import dumps, JSONDecodeError
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Union
|
||||
|
||||
@ -27,12 +31,12 @@ def test_json_read_valid(path: Union[str, Path], expected: Any):
|
||||
@pytest.mark.parametrize(
|
||||
"path, expected",
|
||||
[
|
||||
("tests/data/invalid.json", pytest.raises(JSONDecodeError)),
|
||||
("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)),
|
||||
("tests/data/invalid.json", JSONDecodeError),
|
||||
("tests/data/nonexistent.json", FileNotFoundError),
|
||||
],
|
||||
)
|
||||
def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
||||
with expected:
|
||||
with pytest.raises(expected):
|
||||
assert sync.json_read(path) == expected
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user