diff --git a/src/jsonyx/_manipulator.py b/src/jsonyx/_manipulator.py index a33b0c9..e72a950 100644 --- a/src/jsonyx/_manipulator.py +++ b/src/jsonyx/_manipulator.py @@ -2,6 +2,7 @@ """JSON manipulator.""" # TODO(Nice Zombies): add error messages # TODO(Nice Zombies): raise JSONSyntaxError +# TODO(Nice Zombies): remove value comparison # TODO(Nice Zombies): update schema ID from __future__ import annotations diff --git a/src/jsonyx/_speedups.c b/src/jsonyx/_speedups.c index af934cb..a9c1b95 100644 --- a/src/jsonyx/_speedups.c +++ b/src/jsonyx/_speedups.c @@ -1,5 +1,6 @@ /* JSON speedups */ // TODO(Nice Zombies): speed up decoding +// https://github.com/benfred/py-spy#can-py-spy-profile-native-extensions #include #include diff --git a/src/jsonyx/test/test_dumps.py b/src/jsonyx/test/test_dumps.py index 3128d3d..1cf6e21 100644 --- a/src/jsonyx/test/test_dumps.py +++ b/src/jsonyx/test/test_dumps.py @@ -222,8 +222,11 @@ def test_list_indent( @pytest.mark.parametrize(("indent", "expected"), [ + # Integer (0, ""), (1, " "), + + # String ("\t", "\t"), ]) def test_list_indent_leaves( @@ -394,8 +397,11 @@ def test_dict_indent( @pytest.mark.parametrize(("indent", "expected"), [ + # Integer (0, ""), (1, " "), + + # String ("\t", "\t"), ]) def test_dict_indent_leaves( diff --git a/src/jsonyx/test/test_load_query_value.py b/src/jsonyx/test/test_load_query_value.py index 15c4209..c5a8571 100644 --- a/src/jsonyx/test/test_load_query_value.py +++ b/src/jsonyx/test/test_load_query_value.py @@ -164,7 +164,7 @@ def test_invalid_string(s: str, msg: str, colno: int, end_colno: int) -> None: check_syntax_err(exc_info, msg, colno, end_colno) -@pytest.mark.parametrize("s", ["", "foo"]) +@pytest.mark.parametrize("s", ["", "NaN"]) def test_expecting_value(s: str) -> None: """Test expecting JSON value.""" with pytest.raises(JSONSyntaxError) as exc_info: diff --git a/src/jsonyx/test/test_loads.py b/src/jsonyx/test/test_loads.py index ce65b3c..9ac87ac 100644 --- a/src/jsonyx/test/test_loads.py +++ b/src/jsonyx/test/test_loads.py @@ -281,6 +281,10 @@ def test_array(json: ModuleType, s: str, expected: list[object]) -> None: @pytest.mark.parametrize(("s", "expected"), [ + # No whitespace + ("[]", []), + ("[1,2,3]", [1, 2, 3]), + # In empty array ("[ ]", []), @@ -360,6 +364,10 @@ def test_object(json: ModuleType, s: str, expected: dict[str, object]) -> None: @pytest.mark.parametrize(("s", "expected"), [ + # No whitespace + ("{}", {}), + ('{"a":1,"b":2,"c":3}', {"a": 1, "b": 2, "c": 3}), + # In empty object ("{ }", {}), @@ -534,6 +542,9 @@ def test_recursion(json: ModuleType, start: str) -> None: @pytest.mark.parametrize("s", [ + # No whitespace + "0", + # Before value " 0", diff --git a/src/jsonyx/test/test_run_filter_query.py b/src/jsonyx/test/test_run_filter_query.py index 75cc844..c83b9f7 100644 --- a/src/jsonyx/test/test_run_filter_query.py +++ b/src/jsonyx/test/test_run_filter_query.py @@ -78,6 +78,9 @@ def test_operator(query: str, keep: bool) -> None: # noqa: FBT001 @pytest.mark.parametrize("query", [ + # No whitespace + "@==0", + # Before operator "@ ==0", @@ -86,7 +89,7 @@ def test_operator(query: str, keep: bool) -> None: # noqa: FBT001 ]) def test_operator_whitespace(query: str) -> None: """Test whitespace around operator.""" - assert run_filter_query([], query) == [] + assert not run_filter_query([], query) @pytest.mark.parametrize(("obj", "keep"), [ @@ -131,11 +134,9 @@ def test_whitespace(query: str) -> None: ("$", "Expecting a relative query", 1, -1), ("!", "Expecting a relative query", 2, -1), ("@?", "Optional marker is not allowed", 2, 3), - ("@[@]", "Filter is not allowed", 3, -1), ("@ == ", "Expecting value", 6, -1), ("@ == $", "Expecting value", 6, -1), ("@ == @?", "Optional marker is not allowed", 7, 8), - ("@ == @[@]", "Filter is not allowed", 8, -1), ("@ && ", "Expecting a relative query", 6, -1), ("!@ == @", "Unexpected operator", 4, 6), ("@ @ @", "Expecting end of file", 2, -1),