samir-nasibli commented on code in PR #44434:
URL: https://github.com/apache/arrow/pull/44434#discussion_r1836632205
##########
python/scripts/test_scalar.py:
##########
@@ -0,0 +1,28 @@
+import pyarrow as pa
+
+# Class with valid __arrow_c_array__ method that returns a length-1 array
+class CustomCapsule:
+ def __arrow_c_array__(self):
+ return pa.array([42])
+
+# Test case to check that a scalar can be created from an object with
__arrow_c_array__
+# Adjusting the test to expect the current behavior, which is an ArrowInvalid
error
+def test_scalar_with_capsule():
+ capsule = CustomCapsule()
+ try:
+ pa.scalar(capsule)
+ except pa.lib.ArrowInvalid as e:
+ assert "did not recognize Python value type" in str(e)
+
+# Class with invalid __arrow_c_array__ method that returns an array of length
> 1
+# Adjusting the test to expect the current behavior, which is an ArrowInvalid
error
+def test_scalar_invalid_length():
+ class InvalidCapsule:
+ def __arrow_c_array__(self):
+ return pa.array([1, 2])
+
+ capsule = InvalidCapsule()
+ try:
+ pa.scalar(capsule)
+ except pa.lib.ArrowInvalid as e:
+ assert "did not recognize Python value type" in str(e)
Review Comment:
```suggestion
assert "did not recognize Python value type" in str(e)
```
please add new line at the end of file
--
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]