-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
To string with encoding #28951
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
To string with encoding #28951
Changes from 15 commits
ae76e46
3985040
8eea18e
d2c70ee
835b22d
4e30d7c
78ba34b
56fdad9
83ccffd
19801bb
d44afa7
b4b983b
acb2c6e
236db38
93e8b11
1f3e55d
b0364d2
12ddc8f
f82fe78
5ef9cec
df58c1f
496f68f
725b2ec
698d3b7
96cc810
1a35eeb
f865ac3
757a1f5
835cdb8
648fa55
3698a2a
f8917de
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 |
---|---|---|
|
@@ -3241,12 +3241,12 @@ def test_repr_html_ipython_config(ip): | |
|
||
@pytest.mark.parametrize("method", ["to_string", "to_html", "to_latex"]) | ||
def test_filepath_or_buffer_arg( | ||
float_frame, method, filepath_or_buffer, assert_filepath_or_buffer_equals | ||
float_frame, method, filepath_or_buffer, assert_filepath_or_buffer_equals, encoding | ||
simonjayhawkins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
): | ||
df = 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. Is there a reason to use 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. @simonjayhawkins 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. maybe.. diff --git a/pandas/tests/io/formats/test_format.py b/pandas/tests/io/formats/test_format.py
index 096fc6cb4..dc2784a7b 100644
--- a/pandas/tests/io/formats/test_format.py
+++ b/pandas/tests/io/formats/test_format.py
@@ -3240,16 +3240,19 @@ def test_repr_html_ipython_config(ip):
@pytest.mark.parametrize("method", ["to_string", "to_html", "to_latex"])
-@pytest.mark.parametrize("encoding", [None, "utf-8", "gbk", "foo"])
+@pytest.mark.parametrize(
+ "encoding, data",
+ [(None, "abc"), ("utf-8", "abc"), ("gbk", "造成输出中文显示乱码"), ("foo", "abc")],
+)
def test_filepath_or_buffer_arg(
- float_frame,
method,
filepath_or_buffer,
assert_filepath_or_buffer_equals,
encoding,
+ data,
filepath_or_buffer_id,
):
- df = float_frame
+ df = DataFrame([data])
if filepath_or_buffer_id not in ["string", "pathlike"] and encoding is not None:
with pytest.raises( 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. Looks fine, I'll make the changes and push. |
||
expected = getattr(df, method)() | ||
|
||
getattr(df, method)(buf=filepath_or_buffer) | ||
getattr(df, method)(buf=filepath_or_buffer, encoding=encoding) | ||
assert_filepath_or_buffer_equals(expected) | ||
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.