forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARROW-17016: [C++][Python] Move Arrow Python C++ tests into Cython (a…
…pache#14117) This PR tries to connect the PyArrow C++ tests with PyArrow tests so they can all be run from `pytest`. This will remove GoogleTest as a dependency for PyArrow and therefore a change is needed in the C++ tests so they return a Status which can then be checked through Cython/Python. Example of pytest run: ``` pyarrow/tests/test_cpp_internals.py::test_owned_ref_moves PASSED pyarrow/tests/test_cpp_internals.py::test_owned_ref_nogil_moves PASSED pyarrow/tests/test_cpp_internals.py::test_check_pyerror_status PASSED pyarrow/tests/test_cpp_internals.py::test_check_pyerror_status_nogil PASSED pyarrow/tests/test_cpp_internals.py::test_restore_pyerror_basics PASSED pyarrow/tests/test_cpp_internals.py::test_pybuffer_invalid_input_object PASSED pyarrow/tests/test_cpp_internals.py::test_pybuffer_numpy_array PASSED pyarrow/tests/test_cpp_internals.py::test_numpybuffer_numpy_array PASSED pyarrow/tests/test_cpp_internals.py::test_python_decimal_to_string PASSED pyarrow/tests/test_cpp_internals.py::test_infer_precision_and_scale PASSED pyarrow/tests/test_cpp_internals.py::test_infer_precision_and_negative_scale PASSED pyarrow/tests/test_cpp_internals.py::test_infer_all_leading_zeros PASSED pyarrow/tests/test_cpp_internals.py::test_infer_all_leading_zeros_exponential_notation_positive PASSED pyarrow/tests/test_cpp_internals.py::test_infer_all_leading_zeros_exponential_notation_negative PASSED pyarrow/tests/test_cpp_internals.py::test_object_block_write_fails PASSED pyarrow/tests/test_cpp_internals.py::test_mixed_type_fails PASSED pyarrow/tests/test_cpp_internals.py::test_from_python_decimal_rescale_not_truncateable PASSED pyarrow/tests/test_cpp_internals.py::test_from_python_decimal_rescale_truncateable PASSED pyarrow/tests/test_cpp_internals.py::test_from_python_negative_decimal_rescale PASSED pyarrow/tests/test_cpp_internals.py::test_decimal128_from_python_integer PASSED pyarrow/tests/test_cpp_internals.py::test_decimal256_from_python_integer PASSED pyarrow/tests/test_cpp_internals.py::test_decimal128_overflow_fails PASSED pyarrow/tests/test_cpp_internals.py::test_decimal256_overflow_fails PASSED pyarrow/tests/test_cpp_internals.py::test_none_and_nan PASSED pyarrow/tests/test_cpp_internals.py::test_mixed_precision_and_scale PASSED pyarrow/tests/test_cpp_internals.py::test_mixed_precision_and_scale_sequence_convert PASSED pyarrow/tests/test_cpp_internals.py::test_simple_inference PASSED pyarrow/tests/test_cpp_internals.py::test_update_with_nan PASSED ``` Lead-authored-by: Alenka Frim <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
- Loading branch information
Showing
8 changed files
with
519 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# cython: profile=False, binding=True | ||
# distutils: language = c++ | ||
|
||
from pyarrow.includes.common cimport * | ||
from pyarrow.includes.libarrow cimport * | ||
from pyarrow.lib cimport check_status | ||
|
||
from pyarrow.lib import frombytes | ||
|
||
|
||
cdef class CppTestCase: | ||
""" | ||
A simple wrapper for a C++ test case. | ||
""" | ||
cdef: | ||
CTestCase c_case | ||
|
||
@staticmethod | ||
cdef wrap(CTestCase c_case): | ||
cdef: | ||
CppTestCase obj | ||
obj = CppTestCase.__new__(CppTestCase) | ||
obj.c_case = c_case | ||
return obj | ||
|
||
@property | ||
def name(self): | ||
return frombytes(self.c_case.name) | ||
|
||
def __repr__(self): | ||
return f"<{self.__class__.__name__} {self.name!r}>" | ||
|
||
def __call__(self): | ||
check_status(self.c_case.func()) | ||
|
||
|
||
def get_cpp_tests(): | ||
""" | ||
Get a list of C++ test cases. | ||
""" | ||
cases = [] | ||
c_cases = GetCppTestCases() | ||
for c_case in c_cases: | ||
cases.append(CppTestCase.wrap(c_case)) | ||
return cases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.