Skip to content

Commit

Permalink
Decrease lines
Browse files Browse the repository at this point in the history
  • Loading branch information
nineteendo committed Sep 18, 2024
1 parent b79be48 commit 1ab8b4e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/jsonyx/test/test_dumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ def test_list_recursion(json: ModuleType) -> None:
@pytest.mark.parametrize("obj", [UserList([1, 2, 3]), range(1, 4), (1, 2, 3)])
def test_seq_types(json: ModuleType, obj: Sequence[object]) -> None:
"""Test seq_types."""
s: str = json.dumps(obj, end="", seq_types=(UserList, range))
assert s == "[1, 2, 3]"
assert json.dumps(obj, end="", seq_types=(UserList, range)) == "[1, 2, 3]"


@pytest.mark.parametrize(("obj", "expected"), [
Expand Down Expand Up @@ -301,9 +300,8 @@ def test_quoted_keys_ensure_ascii(
json: ModuleType, key: str, expected: str,
) -> None:
"""Test quoted keys with ensure_ascii."""
assert json.dumps(
{key: 0}, end="", ensure_ascii=True, quoted_keys=False,
) == f'{{"{expected}": 0}}'
s: str = json.dumps({key: 0}, end="", ensure_ascii=True, quoted_keys=False)
assert s == f'{{"{expected}": 0}}'


@pytest.mark.parametrize(("key", "expected"), [
Expand Down
3 changes: 1 addition & 2 deletions src/jsonyx/test/test_loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ def test_duplicate_key(json: ModuleType) -> None:
def test_reuse_keys(json: ModuleType) -> None:
"""Test if keys are re-used."""
dcts: list[dict[str, int]] = json.loads('[{"": 1}, {"": 2}, {"": 3}]')
ids: set[int] = {id(key) for dct in dcts for key in dct}
assert len(ids) == 1
assert len({id(key) for dct in dcts for key in dct}) == 1


@pytest.mark.parametrize("s", ["", "-", "foo"])
Expand Down
5 changes: 2 additions & 3 deletions src/jsonyx/test/test_syntax_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,5 @@ def test_string(
) -> None:
"""Test string representation."""
exc: JSONSyntaxError = JSONSyntaxError("msg", "<string>", doc, 5, end)
assert str(exc) == (
f"msg (<string>, line {line_range}, column {column_range})"
)
expected: str = f"msg (<string>, line {line_range}, column {column_range})"
assert str(exc) == expected

0 comments on commit 1ab8b4e

Please sign in to comment.