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 pathlib import Path
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
@ -29,13 +33,13 @@ async def test_json_read_valid(path: Union[str, Path], expected: Any):
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"path, expected",
|
"path, expected",
|
||||||
[
|
[
|
||||||
("tests/data/invalid.json", pytest.raises(JSONDecodeError)),
|
("tests/data/invalid.json", JSONDecodeError),
|
||||||
("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)),
|
("tests/data/nonexistent.json", FileNotFoundError),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
async def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
||||||
with expected:
|
with pytest.raises(expected):
|
||||||
assert await json_read(path) == expected
|
await json_read(path)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@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 pathlib import Path
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
@ -27,12 +31,12 @@ def test_json_read_valid(path: Union[str, Path], expected: Any):
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"path, expected",
|
"path, expected",
|
||||||
[
|
[
|
||||||
("tests/data/invalid.json", pytest.raises(JSONDecodeError)),
|
("tests/data/invalid.json", JSONDecodeError),
|
||||||
("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)),
|
("tests/data/nonexistent.json", FileNotFoundError),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
||||||
with expected:
|
with pytest.raises(expected):
|
||||||
assert sync.json_read(path) == expected
|
assert sync.json_read(path) == expected
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user