jorisvandenbossche commented on code in PR #14117:
URL: https://github.com/apache/arrow/pull/14117#discussion_r976495629


##########
python/pyarrow/src/python_test.cc:
##########
@@ -92,81 +131,115 @@ std::string FormatPythonException(const std::string& 
exc_class_name) {
   return ss.str();
 }
 
-TEST(CheckPyError, TestStatus) {
+Status TestCheckPyErrorStatus() {
   Status st;
-
-  auto check_error = [](Status& st, const char* expected_message = "some 
error",
-                        std::string expected_detail = "") {
-    st = CheckPyError();
-    ASSERT_EQ(st.message(), expected_message);
-    ASSERT_FALSE(PyErr_Occurred());
-    if (expected_detail.size() > 0) {
-      auto detail = st.detail();
-      ASSERT_NE(detail, nullptr);
-      ASSERT_EQ(detail->ToString(), expected_detail);
-    }
-  };
+  std::string expected_detail = "";
+
+  // auto check_error = [](Status& st, const char* expected_message = "some 
error",
+  //                       std::string expected_detail = "") {
+  //   st = CheckPyError();
+  //   ASSERT_EQ(st.message(), expected_message);
+  //   ASSERT_FALSE_PY(PyErr_Occurred());
+  //   if (expected_detail.size() > 0) {
+  //     auto detail = st.detail();
+  //     ASSERT_NE(detail, nullptr);
+  //     ASSERT_EQ(detail->ToString(), expected_detail);
+  //   }
+  // };
 
   for (PyObject* exc_type : {PyExc_Exception, PyExc_SyntaxError}) {
     PyErr_SetString(exc_type, "some error");
-    check_error(st);
+    //check_error(st);

Review Comment:
   I was testing this locally, and the following patch seems to work to get 
this inline lambda function working again:
   
   ```diff
   --- a/python/pyarrow/src/python_test.cc
   +++ b/python/pyarrow/src/python_test.cc
   @@ -135,24 +135,22 @@ Status TestCheckPyErrorStatus() {
      Status st;
      std::string expected_detail = "";
    
   -  // auto check_error = [](Status& st, const char* expected_message = "some 
error",
   -  //                       std::string expected_detail = "") {
   -  //   st = CheckPyError();
   -  //   ASSERT_EQ(st.message(), expected_message);
   -  //   ASSERT_FALSE_PY(PyErr_Occurred());
   -  //   if (expected_detail.size() > 0) {
   -  //     auto detail = st.detail();
   -  //     ASSERT_NE(detail, nullptr);
   -  //     ASSERT_EQ(detail->ToString(), expected_detail);
   -  //   }
   -  // };
   +  auto check_error = [](Status &st, const char* expected_message = "some 
error",
   +                        std::string expected_detail = "") {
   +    st = CheckPyError();
   +    ASSERT_EQ(st.message(), expected_message);
   +    ASSERT_FALSE_PY(PyErr_Occurred());
   +    if (expected_detail.size() > 0) {
   +      auto detail = st.detail();
   +      ASSERT_NE(detail, nullptr);
   +      ASSERT_EQ(detail->ToString(), expected_detail);
   +    }
   +    return Status::OK();
   +  };
    
      for (PyObject* exc_type : {PyExc_Exception, PyExc_SyntaxError}) {
        PyErr_SetString(exc_type, "some error");
   -    //check_error(st);
   -    st = CheckPyError();
   -    ASSERT_EQ(st.message(), "some error");
   -    ASSERT_FALSE_PY(PyErr_Occurred());
   +    ASSERT_OK(check_error(st));
        ASSERT_TRUE(st.IsUnknownError());
      }
   ```
   
   (the main change is adding a `return Status::OK();` at the end of it)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to