Skip to content

Commit

Permalink
Update tests/test_ujson.py
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
  • Loading branch information
Erotemic and hugovk committed Apr 4, 2022
1 parent 3f9f907 commit 9f03262
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions tests/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,47 +699,47 @@ def test_special_singletons():


@pytest.mark.parametrize(
"test_input, expected_exception, expected_message",
"test_input, expected_message",
[
("n", ujson.JSONDecodeError, "Unexpected character .* 'null'"),
("N", ujson.JSONDecodeError, "Unexpected character .*'NaN'"),
("NA", ujson.JSONDecodeError, "Unexpected character .* 'NaN'"),
("Na N", ujson.JSONDecodeError, "Unexpected character .* 'NaN'"),
("nan", ujson.JSONDecodeError, "Unexpected character .* 'null'"),
("none", ujson.JSONDecodeError, "Unexpected character .* 'null'"),
("i", ujson.JSONDecodeError, "Expected object or value"),
("I", ujson.JSONDecodeError, "Unexpected character .* 'Infinity'"),
("Inf", ujson.JSONDecodeError, "Unexpected character .* 'Infinity'"),
("InfinitY", ujson.JSONDecodeError, "Unexpected character .* 'Infinity'"),
("-i", ujson.JSONDecodeError, "Trailing data"),
("-I", ujson.JSONDecodeError, "Unexpected character .* '-Infinity'"),
("-Inf", ujson.JSONDecodeError, "Unexpected character .* '-Infinity'"),
("-InfinitY", ujson.JSONDecodeError, "Unexpected character .* '-Infinity'"),
("- i", ujson.JSONDecodeError, "Trailing data"),
("- I", ujson.JSONDecodeError, "Trailing data"),
("- Inf", ujson.JSONDecodeError, "Trailing data"),
("- InfinitY", ujson.JSONDecodeError, "Trailing data"),
("n", "Unexpected character .* 'null'"),
("N", "Unexpected character .*'NaN'"),
("NA", "Unexpected character .* 'NaN'"),
("Na N", "Unexpected character .* 'NaN'"),
("nan", "Unexpected character .* 'null'"),
("none", "Unexpected character .* 'null'"),
("i", "Expected object or value"),
("I", "Unexpected character .* 'Infinity'"),
("Inf", "Unexpected character .* 'Infinity'"),
("InfinitY", "Unexpected character .* 'Infinity'"),
("-i", "Trailing data"),
("-I", "Unexpected character .* '-Infinity'"),
("-Inf", "Unexpected character .* '-Infinity'"),
("-InfinitY", "Unexpected character .* '-Infinity'"),
("- i", "Trailing data"),
("- I", "Trailing data"),
("- Inf", "Trailing data"),
("- InfinitY", "Trailing data"),
],
)
def test_incomplete_special_inputs(test_input, expected_exception, expected_message):
with pytest.raises(expected_exception, match=expected_message):
print(f"test_input = {test_input!r}")
def test_incomplete_special_inputs(test_input, expected_message):
with pytest.raises(ujson.JSONDecodeError, match=expected_message):
print("test_input = {!r}".format(test_input))
ujson.loads(test_input)


@pytest.mark.parametrize(
"test_input, expected_exception, expected_message",
"test_input, expected_message",
[
("NaNaNaN", ujson.JSONDecodeError, "Trailing data"),
("Infinity and Beyond", ujson.JSONDecodeError, "Trailing data"),
("-Infinity-and-Beyond", ujson.JSONDecodeError, "Trailing data"),
("NaN!", ujson.JSONDecodeError, "Trailing data"),
("Infinity!", ujson.JSONDecodeError, "Trailing data"),
("-Infinity!", ujson.JSONDecodeError, "Trailing data"),
("NaNaNaN", "Trailing data"),
("Infinity and Beyond", "Trailing data"),
("-Infinity-and-Beyond", "Trailing data"),
("NaN!", "Trailing data"),
("Infinity!", "Trailing data"),
("-Infinity!", "Trailing data"),
],
)
def test_overcomplete_special_inputs(test_input, expected_exception, expected_message):
with pytest.raises(expected_exception, match=expected_message):
def test_overcomplete_special_inputs(test_input, expected_message):
with pytest.raises(ujson.JSONDecodeError, match=expected_message):
ujson.loads(test_input)


Expand Down

0 comments on commit 9f03262

Please sign in to comment.