[ 
https://issues.apache.org/jira/browse/ARROW-17016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17605992#comment-17605992
 ] 

Antoine Pitrou commented on ARROW-17016:
----------------------------------------

Cython does not really allow to express C++ concepts precisely. So some tests 
have to be written in C++.
If we don't want to use GTest, then we could perhaps still write some tests in 
C++, have them return a {{Status}}, then execute them from pytest?

Draft example:
{code:c++}
#define ASSERT_EQ(x, y) { \
  auto&& _left = (x); \
  auto&& _right = (y); \
  if (_left != _right) { \
    return Status::Invalid("Expected equality but ", _left, " != ", _right); \
  } \
}

Status TestOwnedRefMoves() {
  std::vector<OwnedRef> vec;
  PyObject *u, *v;
  u = PyList_New(0);
  v = PyList_New(0);
  {
    OwnedRef ref(u);
    vec.push_back(std::move(ref));
    ASSERT_EQ(ref.obj(), nullptr);
  }
  vec.emplace_back(v);
  ASSERT_EQ(Py_REFCNT(u), 1);
  ASSERT_EQ(Py_REFCNT(v), 1);
  return Status::Ok();
}
{code}

{code:python}
# Cython test code

def test_owned_ref_moves():
    check_status(TestOwnedRefMoves())
{code}


> [C++][Python] Run Arrow Python C++ with pytest and make sure they are run by 
> the CI
> -----------------------------------------------------------------------------------
>
>                 Key: ARROW-17016
>                 URL: https://issues.apache.org/jira/browse/ARROW-17016
>             Project: Apache Arrow
>          Issue Type: Sub-task
>          Components: C++, Python
>            Reporter: Alenka Frim
>            Assignee: Alenka Frim
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 10.0.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> After [https://github.com/apache/arrow/pull/13311] is merged{-}, the tests 
> for C PyArrow should be moved to Cython and the documentation about running 
> the tests with GTest should be removed.{-} we should:
>  - try to run the tests from the pytest to make the whole process of code 
> quality check simplified.
>  - make sure the CI runs these PyArrow C++ test. Currently they are not being 
> run on the CI due to all the builds having GTest not bundled, see: 
> [https://arrow.apache.org/docs/dev/developers/python.html#testing-pyarrow-c]
> TheĀ  migration of the tests to Cython has not proved as a good option as 
> there are couple of tests that should stay in the C++, for example 
> [TestMoves|https://github.com/apache/arrow/blob/master/python/pyarrow/src/python_test.cc#L48-L62]
>  and similar. For this reason we will find some other solution to keep using 
> GTest and run them with pytest, if possible.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to