Skip to content

Commit

Permalink
apacheGH-41043: [CI][Python] check message in test_make_write_options…
Browse files Browse the repository at this point in the history
…_error for Cython 2 (apache#41059)

### Rationale for this change

`test_make_write_options_error` has been failing on Cython 2 crossbow build because in older versions of Cython the methods were "regular" C extension method had type check automatically built in. In Cython 3 that is not the case, see cython/cython#6127 and so the check for `ParquetFileFormat` was added in apache#40976.

### What changes are included in this PR?

Checking the error raised for both messages, type check and the check for `ParquetFileFormat` added in apache#40976.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: apache#41043

Authored-by: AlenkaF <frim.alenka@gmail.com>
Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
  • Loading branch information
AlenkaF authored and rok committed May 8, 2024
1 parent 7ec273c commit 8b71b49
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5633,11 +5633,17 @@ def test_checksum_write_dataset_read_dataset_to_table(tempdir):


def test_make_write_options_error():
# GH-39440
msg = ("make_write_options\\(\\) should be called on an "
"instance of ParquetFileFormat")
with pytest.raises(TypeError, match=msg):
# GH-39440: calling make_write_options as a static class method
msg_1 = ("make_write_options() should be called on an "
"instance of ParquetFileFormat")
# GH-41043: In Cython2 all Cython methods were "regular" C extension methods
# see: https://github.com/cython/cython/issues/6127#issuecomment-2038153359
msg_2 = ("descriptor 'make_write_options' for "
"'pyarrow._dataset_parquet.ParquetFileFormat' objects "
"doesn't apply to a 'int'")
with pytest.raises(TypeError) as excinfo:
pa.dataset.ParquetFileFormat.make_write_options(43)
assert msg_1 in str(excinfo.value) or msg_2 in str(excinfo.value)

pformat = pa.dataset.ParquetFileFormat()
msg = "make_write_options\\(\\) takes exactly 0 positional arguments"
Expand Down

0 comments on commit 8b71b49

Please sign in to comment.