Skip to content

Commit 649f6ce

Browse files
committed
CLN: Remove vestigial references to PY2 in tests
1 parent 9821b77 commit 649f6ce

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

pandas/tests/arithmetic/test_period.py

+17-25
Original file line numberDiff line numberDiff line change
@@ -1046,34 +1046,26 @@ def test_pi_ops(self):
10461046
exp = pd.Index([0 * off, -1 * off, -2 * off, -3 * off], name='idx')
10471047
tm.assert_index_equal(result, exp)
10481048

1049-
@pytest.mark.parametrize('ng', ["str", 1.5])
1050-
def test_parr_ops_errors(self, ng, box_with_array):
1051-
idx = PeriodIndex(['2011-01', '2011-02', '2011-03', '2011-04'],
1052-
freq='M', name='idx')
1049+
@pytest.mark.parametrize("ng", ["str", 1.5])
1050+
@pytest.mark.parametrize("func", [
1051+
lambda obj, ng: obj + ng,
1052+
lambda obj, ng: ng + obj,
1053+
lambda obj, ng: obj - ng,
1054+
lambda obj, ng: ng - obj,
1055+
lambda obj, ng: np.add(obj, ng),
1056+
lambda obj, ng: np.add(ng, obj),
1057+
lambda obj, ng: np.subtract(obj, ng),
1058+
lambda obj, ng: np.subtract(ng, obj),
1059+
])
1060+
def test_parr_ops_errors(self, ng, func, box_with_array):
1061+
idx = PeriodIndex(["2011-01", "2011-02", "2011-03", "2011-04"],
1062+
freq="M", name="idx")
10531063
obj = tm.box_expected(idx, box_with_array)
1054-
1055-
msg = r"unsupported operand type\(s\)"
1056-
with pytest.raises(TypeError, match=msg):
1057-
obj + ng
1058-
1059-
with pytest.raises(TypeError):
1060-
# error message differs between PY2 and 3
1061-
ng + obj
1064+
msg = (r"unsupported operand type\(s\)|can only concatenate|"
1065+
r"must be str|object to str implicitly")
10621066

10631067
with pytest.raises(TypeError, match=msg):
1064-
obj - ng
1065-
1066-
with pytest.raises(TypeError):
1067-
np.add(obj, ng)
1068-
1069-
with pytest.raises(TypeError):
1070-
np.add(ng, obj)
1071-
1072-
with pytest.raises(TypeError):
1073-
np.subtract(obj, ng)
1074-
1075-
with pytest.raises(TypeError):
1076-
np.subtract(ng, obj)
1068+
func(obj, ng)
10771069

10781070
def test_pi_ops_nat(self):
10791071
idx = PeriodIndex(['2011-01', '2011-02', 'NaT', '2011-04'],

pandas/tests/frame/test_indexing.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -2581,11 +2581,9 @@ def test_boolean_indexing_mixed(self):
25812581
assert_frame_equal(df2, expected)
25822582

25832583
df['foo'] = 'test'
2584-
msg = ("boolean setting on mixed-type|"
2585-
"not supported between|"
2586-
"unorderable types")
2584+
msg = "not supported between instances|unorderable types"
2585+
25872586
with pytest.raises(TypeError, match=msg):
2588-
# TODO: This message should be the same in PY2/PY3
25892587
df[df > 0.3] = 1
25902588

25912589
def test_where(self):

pandas/tests/series/test_repr.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ def test_index_repr_in_frame_with_nan(self):
203203
class TestCategoricalRepr(object):
204204

205205
def test_categorical_repr_unicode(self):
206-
# GH#21002 if len(index) > 60, sys.getdefaultencoding()=='ascii',
207-
# and we are working in PY2, then rendering a Categorical could raise
208-
# UnicodeDecodeError by trying to decode when it shouldn't
206+
# see gh-21002
209207

210208
class County(StringMixin):
211209
name = u'San Sebastián'
@@ -214,7 +212,7 @@ class County(StringMixin):
214212
def __unicode__(self):
215213
return self.name + u', ' + self.state
216214

217-
cat = pd.Categorical([County() for n in range(61)])
215+
cat = pd.Categorical([County() for _ in range(61)])
218216
idx = pd.Index(cat)
219217
ser = idx.to_series()
220218

0 commit comments

Comments
 (0)