Skip to content

TST: Add test_ to four tests in test_readlines.py and fix two of them #50445

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

Merged
merged 3 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,3 @@ repos:
exclude: |
(?x)
^pandas/tests/generic/test_generic.py # GH50380
|^pandas/tests/io/json/test_readlines.py # GH50378
14 changes: 8 additions & 6 deletions pandas/tests/io/json/test_readlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def test_to_json_append_mode(mode_):
df.to_json(mode=mode_, lines=False, orient="records")


def to_json_append_output_consistent_columns():
def test_to_json_append_output_consistent_columns():
# GH 35849
# Testing that resulting output reads in as expected.
# Testing same columns, new rows
Expand All @@ -354,7 +354,7 @@ def to_json_append_output_consistent_columns():
tm.assert_frame_equal(result, expected)


def to_json_append_output_inconsistent_columns():
def test_to_json_append_output_inconsistent_columns():
# GH 35849
# Testing that resulting output reads in as expected.
# Testing one new column, one old column, new rows
Expand All @@ -378,7 +378,7 @@ def to_json_append_output_inconsistent_columns():
tm.assert_frame_equal(result, expected)


def to_json_append_output_different_columns():
def test_to_json_append_output_different_columns():
# GH 35849
# Testing that resulting output reads in as expected.
# Testing same, differing and new columns
Expand All @@ -387,12 +387,13 @@ def to_json_append_output_different_columns():
df3 = DataFrame({"col2": ["e", "f"], "col3": ["!", "#"]})
df4 = DataFrame({"col4": [True, False]})

# Booleans here converted to integers to agree with data created by "to_json"
expected = DataFrame(
{
"col1": [1, 2, 3, 4, None, None, None, None],
"col2": ["a", "b", "c", "d", "e", "f", None, None],
"col3": [None, None, None, None, "!", "#", None, None],
"col4": [None, None, None, None, None, None, True, False],
"col4": [None, None, None, None, None, None, int(True), int(False)],
}
)
with tm.ensure_clean("test.json") as path:
Expand All @@ -407,7 +408,7 @@ def to_json_append_output_different_columns():
tm.assert_frame_equal(result, expected)


def to_json_append_output_different_columns_reordered():
def test_to_json_append_output_different_columns_reordered():
# GH 35849
# Testing that resulting output reads in as expected.
# Testing specific result column order.
Expand All @@ -417,9 +418,10 @@ def to_json_append_output_different_columns_reordered():
df4 = DataFrame({"col4": [True, False]})

# df4, df3, df2, df1 (in that order)
# Booleans here converted to integers to agree with data created by "to_json"
expected = DataFrame(
{
"col4": [True, False, None, None, None, None, None, None],
"col4": [int(True), int(False), None, None, None, None, None, None],
"col2": [None, None, "e", "f", "c", "d", "a", "b"],
"col3": [None, None, "!", "#", None, None, None, None],
"col1": [None, None, None, None, 3, 4, 1, 2],
Expand Down