Skip to content

Commit 1960264

Browse files
committed
test: updates tests with regex matches
1 parent a7e18a2 commit 1960264

File tree

3 files changed

+112
-6
lines changed

3 files changed

+112
-6
lines changed

tests/compliance/date/test_date_compliance.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,15 @@ class TestDtype(base.BaseDtypeTests):
5151

5252

5353
class TestGetitem(base.BaseGetitemTests):
54-
pass
55-
54+
def test_take_pandas_style_negative_raises(self, data, na_value):
55+
# This test was failing compliance checks because it attempted to match
56+
# a pytest regex match using an empty string (""), which pytest version
57+
# 8.4.0 stopped allowing.
58+
# The test has been updated in pandas main so that it will
59+
# no longer fail, but the fix is not expected to be released until
60+
# at least pandas version 3.0 (current version is 2.3).
61+
with pytest.raises(ValueError):
62+
data.take([0, -2], fill_value=na_value, allow_fill=True)
5663

5764
class TestGroupby(base.BaseGroupbyTests):
5865
pass
@@ -102,6 +109,22 @@ def test_hash_pandas_object(self):
102109
further investigation. See issues 182, 183, 185."""
103110
)
104111

112+
def test_argmax_argmin_no_skipna_notimplemented(self, data_missing_for_sorting):
113+
# This test was failing compliance checks because it attempted to match
114+
# a pytest regex match using an empty string (""), which pytest version
115+
# 8.4.0 stopped allowing.
116+
# The test has been updated in pandas main so that it will
117+
# no longer fail, but the fix is not expected to be released until
118+
# at least pandas version 3.0 (current version is 2.3)
119+
data = data_missing_for_sorting
120+
121+
with pytest.raises(NotImplementedError):
122+
data.argmin(skipna=False)
123+
124+
with pytest.raises(NotImplementedError):
125+
data.argmax(skipna=False)
126+
127+
105128

106129
class TestParsing(base.BaseParsingTests):
107130
pass
@@ -116,7 +139,18 @@ class TestReshaping(base.BaseReshapingTests):
116139

117140

118141
class TestSetitem(base.BaseSetitemTests):
119-
pass
142+
# This test was failing compliance checks because it attempted to match
143+
# a pytest regex match using an empty string (""), which pytest version
144+
# 8.4.0 stopped allowing.
145+
# The test has been updated in pandas main so that it will
146+
# no longer fail, but the fix is not expected to be released until
147+
# at least pandas version 3.0 (current version is 2.3).
148+
def test_setitem_invalid(self, data, invalid_scalar):
149+
with pytest.raises((ValueError, TypeError)):
150+
data[0] = invalid_scalar
151+
152+
with pytest.raises((ValueError, TypeError)):
153+
data[:] = invalid_scalar
120154

121155

122156
# NDArrayBacked2DTests suite added in https://github.com/pandas-dev/pandas/pull/44974

tests/compliance/json/test_json_compliance.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ def test_getitem_scalar(self, data):
107107
"""
108108
super().test_getitem_scalar(data)
109109

110+
def test_take_pandas_style_negative_raises(self, data, na_value):
111+
# This test was failing compliance checks because it attempted to match
112+
# a pytest regex match using an empty string (""), which pytest version
113+
# 8.4.0 stopped allowing.
114+
# The test has been updated in pandas main so that it will
115+
# no longer fail, but the fix is not expected to be released until
116+
# at least pandas version 3.0 (current version is 2.3).
117+
with pytest.raises(ValueError):
118+
data.take([0, -2], fill_value=na_value, allow_fill=True)
119+
110120

111121
class TestJSONArrayIndex(base.BaseIndexTests):
112122
pass
@@ -190,6 +200,20 @@ def test_sort_values(self, data_for_sorting):
190200
def test_sort_values_frame(self, data_for_sorting):
191201
super().test_sort_values_frame(data_for_sorting)
192202

203+
def test_argmax_argmin_no_skipna_notimplemented(self, data_missing_for_sorting):
204+
# This test was failing compliance checks because it attempted to match
205+
# a pytest regex match using an empty string (""), which pytest version
206+
# 8.4.0 stopped allowing.
207+
# The test has been updated in pandas main so that it will
208+
# no longer fail, but the fix is not expected to be released until
209+
# at least pandas version 3.0 (current version is 2.3)
210+
data = data_missing_for_sorting
211+
212+
with pytest.raises(NotImplementedError):
213+
data.argmin(skipna=False)
214+
215+
with pytest.raises(NotImplementedError):
216+
data.argmax(skipna=False)
193217

194218
class TestJSONArrayMissing(base.BaseMissingTests):
195219
@pytest.mark.xfail(reason="Setting a dict as a scalar")
@@ -357,5 +381,21 @@ def test_setitem_preserves_views(self, data):
357381
super().test_setitem_preserves_views(data)
358382

359383

384+
def test_setitem_invalid(self, data, invalid_scalar):
385+
# This test was failing compliance checks because it attempted to match
386+
# a pytest regex match using an empty string (""), which pytest version
387+
# 8.4.0 stopped allowing.
388+
# The test has been updated in pandas main so that it will
389+
# no longer fail, but the fix is not expected to be released until
390+
# at least pandas version 3.0 (current version is 2.3)
391+
with pytest.raises((ValueError, TypeError)):
392+
data[0] = invalid_scalar
393+
394+
with pytest.raises((ValueError, TypeError)):
395+
data[:] = invalid_scalar
396+
397+
398+
399+
360400
class TestJSONArrayDim2Compat(base.Dim2CompatTests):
361401
pass

tests/compliance/time/test_time_compliance.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,15 @@ class TestDtype(base.BaseDtypeTests):
5656

5757

5858
class TestGetitem(base.BaseGetitemTests):
59-
pass
60-
59+
def test_take_pandas_style_negative_raises(self, data, na_value):
60+
# This test was failing compliance checks because it attempted to match
61+
# a pytest regex match using an empty string (""), which pytest version
62+
# 8.4.0 stopped allowing.
63+
# The test has been updated in pandas main so that it will
64+
# no longer fail, but the fix is not expected to be released until
65+
# at least pandas version 3.0 (current version is 2.3).
66+
with pytest.raises(ValueError):
67+
data.take([0, -2], fill_value=na_value, allow_fill=True)
6168

6269
class TestGroupby(base.BaseGroupbyTests):
6370
pass
@@ -95,6 +102,20 @@ def test_value_counts(self, all_data, dropna):
95102

96103
tm.assert_series_equal(result, expected)
97104

105+
def test_argmax_argmin_no_skipna_notimplemented(self, data_missing_for_sorting):
106+
# This test was failing compliance checks because it attempted to match
107+
# a pytest regex match using an empty string (""), which pytest version
108+
# 8.4.0 stopped allowing.
109+
# The test has been updated in pandas main so that it will
110+
# no longer fail, but the fix is not expected to be released until
111+
# at least pandas version 3.0 (current version is 2.3)
112+
data = data_missing_for_sorting
113+
114+
with pytest.raises(NotImplementedError):
115+
data.argmin(skipna=False)
116+
117+
with pytest.raises(NotImplementedError):
118+
data.argmax(skipna=False)
98119

99120
class TestParsing(base.BaseParsingTests):
100121
pass
@@ -109,4 +130,15 @@ class TestReshaping(base.BaseReshapingTests):
109130

110131

111132
class TestSetitem(base.BaseSetitemTests):
112-
pass
133+
def test_setitem_invalid(self, data, invalid_scalar):
134+
# This test was failing compliance checks because it attempted to match
135+
# a pytest regex match using an empty string (""), which pytest version
136+
# 8.4.0 stopped allowing.
137+
# The test has been updated in pandas main so that it will
138+
# no longer fail, but the fix is not expected to be released until
139+
# at least pandas version 3.0 (current version is 2.3)
140+
with pytest.raises((ValueError, TypeError)):
141+
data[0] = invalid_scalar
142+
143+
with pytest.raises((ValueError, TypeError)):
144+
data[:] = invalid_scalar

0 commit comments

Comments
 (0)