Skip to content

TST: de-xfail pyarrow dialect tests #56040

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 1 commit into from
Nov 18, 2023
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
42 changes: 37 additions & 5 deletions pandas/tests/io/parser/test_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
pytestmark = pytest.mark.filterwarnings(
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
)
xfail_pyarrow = pytest.mark.usefixtures("pyarrow_xfail")


@pytest.fixture
Expand All @@ -33,7 +32,6 @@ def custom_dialect():
return dialect_name, dialect_kwargs


@xfail_pyarrow # ValueError: The 'dialect' option is not supported
def test_dialect(all_parsers):
parser = all_parsers
data = """\
Expand All @@ -44,6 +42,13 @@ def test_dialect(all_parsers):

dia = csv.excel()
dia.quoting = csv.QUOTE_NONE

if parser.engine == "pyarrow":
msg = "The 'dialect' option is not supported with the 'pyarrow' engine"
with pytest.raises(ValueError, match=msg):
parser.read_csv(StringIO(data), dialect=dia)
return

df = parser.read_csv(StringIO(data), dialect=dia)

data = """\
Expand All @@ -56,7 +61,6 @@ def test_dialect(all_parsers):
tm.assert_frame_equal(df, exp)


@xfail_pyarrow # ValueError: The 'dialect' option is not supported
def test_dialect_str(all_parsers):
dialect_name = "mydialect"
parser = all_parsers
Expand All @@ -68,6 +72,12 @@ def test_dialect_str(all_parsers):
exp = DataFrame({"fruit": ["apple", "pear"], "vegetable": ["broccoli", "tomato"]})

with tm.with_csv_dialect(dialect_name, delimiter=":"):
if parser.engine == "pyarrow":
msg = "The 'dialect' option is not supported with the 'pyarrow' engine"
with pytest.raises(ValueError, match=msg):
parser.read_csv(StringIO(data), dialect=dialect_name)
return

df = parser.read_csv(StringIO(data), dialect=dialect_name)
tm.assert_frame_equal(df, exp)

Expand All @@ -84,7 +94,6 @@ class InvalidDialect:
parser.read_csv(StringIO(data), dialect=InvalidDialect)


@xfail_pyarrow # ValueError: The 'dialect' option is not supported
@pytest.mark.parametrize(
"arg",
[None, "doublequote", "escapechar", "skipinitialspace", "quotechar", "quoting"],
Expand Down Expand Up @@ -114,6 +123,18 @@ def test_dialect_conflict_except_delimiter(all_parsers, custom_dialect, arg, val
kwds[arg] = "blah"

with tm.with_csv_dialect(dialect_name, **dialect_kwargs):
if parser.engine == "pyarrow":
msg = "The 'dialect' option is not supported with the 'pyarrow' engine"
with pytest.raises(ValueError, match=msg):
parser.read_csv_check_warnings(
# No warning bc we raise
None,
"Conflicting values for",
StringIO(data),
dialect=dialect_name,
**kwds,
)
return
result = parser.read_csv_check_warnings(
warning_klass,
"Conflicting values for",
Expand All @@ -124,7 +145,6 @@ def test_dialect_conflict_except_delimiter(all_parsers, custom_dialect, arg, val
tm.assert_frame_equal(result, expected)


@xfail_pyarrow # ValueError: The 'dialect' option is not supported
@pytest.mark.parametrize(
"kwargs,warning_klass",
[
Expand Down Expand Up @@ -153,6 +173,18 @@ def test_dialect_conflict_delimiter(all_parsers, custom_dialect, kwargs, warning
data = "a:b\n1:2"

with tm.with_csv_dialect(dialect_name, **dialect_kwargs):
if parser.engine == "pyarrow":
msg = "The 'dialect' option is not supported with the 'pyarrow' engine"
with pytest.raises(ValueError, match=msg):
parser.read_csv_check_warnings(
# no warning bc we raise
None,
"Conflicting values for 'delimiter'",
StringIO(data),
dialect=dialect_name,
**kwargs,
)
return
result = parser.read_csv_check_warnings(
warning_klass,
"Conflicting values for 'delimiter'",
Expand Down