@@ -49,36 +49,29 @@ def test_hashable():
4949 assert d [NA ] == "test"
5050
5151
52- def test_arithmetic_ops (all_arithmetic_functions ):
52+ @pytest .mark .parametrize (
53+ "other" , [NA , 1 , 1.0 , "a" , b"a" , np .int64 (1 ), np .nan ], ids = repr
54+ )
55+ def test_arithmetic_ops (all_arithmetic_functions , other ):
5356 op = all_arithmetic_functions
5457
55- for other in [NA , 1 , 1.0 , "a" , np .int64 (1 ), np .nan ]:
56- if op .__name__ in ("pow" , "rpow" , "rmod" ) and isinstance (other , str ):
57- continue
58- if op .__name__ in ("divmod" , "rdivmod" ):
59- assert op (NA , other ) is (NA , NA )
60- else :
61- if op .__name__ == "rpow" :
62- # avoid special case
63- other += 1
64- assert op (NA , other ) is NA
65-
66-
67- def test_comparison_ops ():
68-
69- for other in [NA , 1 , 1.0 , "a" , np .int64 (1 ), np .nan , np .bool_ (True )]:
70- assert (NA == other ) is NA
71- assert (NA != other ) is NA
72- assert (NA > other ) is NA
73- assert (NA >= other ) is NA
74- assert (NA < other ) is NA
75- assert (NA <= other ) is NA
76- assert (other == NA ) is NA
77- assert (other != NA ) is NA
78- assert (other > NA ) is NA
79- assert (other >= NA ) is NA
80- assert (other < NA ) is NA
81- assert (other <= NA ) is NA
58+ if op .__name__ in ("pow" , "rpow" , "rmod" ) and isinstance (other , (str , bytes )):
59+ pytest .skip (reason = f"{ op .__name__ } with NA and { other } not defined." )
60+ if op .__name__ in ("divmod" , "rdivmod" ):
61+ assert op (NA , other ) is (NA , NA )
62+ else :
63+ if op .__name__ == "rpow" :
64+ # avoid special case
65+ other += 1
66+ assert op (NA , other ) is NA
67+
68+
69+ @pytest .mark .parametrize (
70+ "other" , [NA , 1 , 1.0 , "a" , b"a" , np .int64 (1 ), np .nan , np .bool_ (True )]
71+ )
72+ def test_comparison_ops (comparison_op , other ):
73+ assert comparison_op (NA , other ) is NA
74+ assert comparison_op (other , NA ) is NA
8275
8376
8477@pytest .mark .parametrize (
0 commit comments