@@ -376,6 +376,33 @@ def test_comparison_methods_array(comparison_op, dtype, dtype2):
376
376
# tm.assert_equal(result, result3)
377
377
378
378
379
+ def test_comparison_methods_list (comparison_op , dtype ):
380
+ op_name = f"__{ comparison_op .__name__ } __"
381
+
382
+ a = pd .array (["a" , None , "c" ], dtype = dtype )
383
+ other = [None , None , "c" ]
384
+ result = comparison_op (a , other )
385
+
386
+ # ensure operation is commutative
387
+ result2 = comparison_op (other , a )
388
+ tm .assert_equal (result , result2 )
389
+
390
+ if dtype .na_value is np .nan :
391
+ if operator .ne == comparison_op :
392
+ expected = np .array ([True , True , False ])
393
+ else :
394
+ expected = np .array ([False , False , False ])
395
+ expected [- 1 ] = getattr (other [- 1 ], op_name )(a [- 1 ])
396
+ tm .assert_numpy_array_equal (result , expected )
397
+
398
+ else :
399
+ expected_dtype = "boolean[pyarrow]" if dtype .storage == "pyarrow" else "boolean"
400
+ expected = np .full (len (a ), fill_value = None , dtype = "object" )
401
+ expected [- 1 ] = getattr (other [- 1 ], op_name )(a [- 1 ])
402
+ expected = pd .array (expected , dtype = expected_dtype )
403
+ tm .assert_extension_array_equal (result , expected )
404
+
405
+
379
406
def test_constructor_raises (cls ):
380
407
if cls is pd .arrays .StringArray :
381
408
msg = "StringArray requires a sequence of strings or pandas.NA"
0 commit comments