-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
More Json parametrize #33148
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
More Json parametrize #33148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
_tsd = tm.getTimeSeriesData() | ||
|
||
_frame = DataFrame(_seriesd) | ||
_frame2 = DataFrame(_seriesd, columns=["D", "C", "B", "A"]) | ||
_intframe = DataFrame({k: v.astype(np.int64) for k, v in _seriesd.items()}) | ||
|
||
_tsframe = DataFrame(_tsd) | ||
|
@@ -44,20 +43,13 @@ def assert_json_roundtrip_equal(result, expected, orient): | |
class TestPandasContainer: | ||
@pytest.fixture(autouse=True) | ||
def setup(self): | ||
self.empty_frame = DataFrame() | ||
self.frame = _frame.copy() | ||
self.frame2 = _frame2.copy() | ||
self.intframe = _intframe.copy() | ||
self.tsframe = _tsframe.copy() | ||
self.mixed_frame = _mixed_frame.copy() | ||
self.categorical = _cat_frame.copy() | ||
|
||
yield | ||
|
||
del self.empty_frame | ||
|
||
del self.frame | ||
del self.frame2 | ||
del self.intframe | ||
del self.tsframe | ||
del self.mixed_frame | ||
|
@@ -126,19 +118,19 @@ def test_frame_non_unique_columns_raises(self, orient): | |
with pytest.raises(ValueError, match=msg): | ||
df.to_json(orient=orient) | ||
|
||
def test_frame_default_orient(self): | ||
assert self.frame.to_json() == self.frame.to_json(orient="columns") | ||
def test_frame_default_orient(self, float_frame): | ||
assert float_frame.to_json() == float_frame.to_json(orient="columns") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||
|
||
@pytest.mark.parametrize("dtype", [False, float]) | ||
@pytest.mark.parametrize("convert_axes", [True, False]) | ||
@pytest.mark.parametrize("numpy", [True, False]) | ||
def test_roundtrip_simple(self, orient, convert_axes, numpy, dtype): | ||
data = self.frame.to_json(orient=orient) | ||
def test_roundtrip_simple(self, orient, convert_axes, numpy, dtype, float_frame): | ||
data = float_frame.to_json(orient=orient) | ||
result = pd.read_json( | ||
data, orient=orient, convert_axes=convert_axes, numpy=numpy, dtype=dtype | ||
) | ||
|
||
expected = self.frame.copy() | ||
expected = float_frame | ||
|
||
assert_json_roundtrip_equal(result, expected, orient) | ||
|
||
|
@@ -226,12 +218,12 @@ def test_roundtrip_categorical(self, orient, convert_axes, numpy): | |
|
||
@pytest.mark.parametrize("convert_axes", [True, False]) | ||
@pytest.mark.parametrize("numpy", [True, False]) | ||
def test_roundtrip_empty(self, orient, convert_axes, numpy): | ||
data = self.empty_frame.to_json(orient=orient) | ||
def test_roundtrip_empty(self, orient, convert_axes, numpy, empty_frame): | ||
data = empty_frame.to_json(orient=orient) | ||
result = pd.read_json( | ||
data, orient=orient, convert_axes=convert_axes, numpy=numpy | ||
) | ||
expected = self.empty_frame.copy() | ||
expected = empty_frame.copy() | ||
|
||
# TODO: both conditions below are probably bugs | ||
if convert_axes: | ||
|
@@ -738,11 +730,10 @@ def test_reconstruction_index(self): | |
result = read_json(df.to_json()) | ||
tm.assert_frame_equal(result, df) | ||
|
||
def test_path(self): | ||
def test_path(self, float_frame): | ||
with tm.ensure_clean("test.json") as path: | ||
for df in [ | ||
self.frame, | ||
self.frame2, | ||
float_frame, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above comment, self.frame and self.frame2 are actually different in that the former uses default column labels whereas the latter used ABCD; I didn't think that distinction was worth creating a separate fixture or object within this test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, but this is a historical accident, having a smaller set of common fixtures is better |
||
self.intframe, | ||
self.tsframe, | ||
self.mixed_frame, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is scattered across a few modules right now that I didn't touch here; can use further here or in a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
followup is fine.