Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: GH30999 add match=msg to 2 pytest.raises in pandas/tests/io/json/test_normalize.py #38864

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions pandas/tests/io/json/test_normalize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from contextlib import nullcontext as does_not_raise
import json

import numpy as np
Expand Down Expand Up @@ -170,19 +169,21 @@ def test_empty_array(self):
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize(
"data, record_path, error",
"data, record_path, exception_type",
[
([{"a": 0}, {"a": 1}], None, does_not_raise()),
({"a": [{"a": 0}, {"a": 1}]}, "a", does_not_raise()),
('{"a": [{"a": 0}, {"a": 1}]}', None, pytest.raises(NotImplementedError)),
(None, None, pytest.raises(NotImplementedError)),
([{"a": 0}, {"a": 1}], None, None),
({"a": [{"a": 0}, {"a": 1}]}, "a", None),
('{"a": [{"a": 0}, {"a": 1}]}', None, NotImplementedError),
(None, None, NotImplementedError),
],
)
def test_accepted_input(self, data, record_path, error):
with error:
def test_accepted_input(self, data, record_path, exception_type):
if exception_type is not None:
with pytest.raises(exception_type, match=tm.EMPTY_STRING_PATTERN):
json_normalize(data, record_path=record_path)
else:
result = json_normalize(data, record_path=record_path)
expected = DataFrame([0, 1], columns=["a"])

tm.assert_frame_equal(result, expected)

def test_simple_normalize_with_separator(self, deep_nested):
Expand Down