Skip to content

CLN: Remove vestigial references to PY2 in tests #25865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions pandas/tests/arithmetic/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,34 +1046,26 @@ def test_pi_ops(self):
exp = pd.Index([0 * off, -1 * off, -2 * off, -3 * off], name='idx')
tm.assert_index_equal(result, exp)

@pytest.mark.parametrize('ng', ["str", 1.5])
def test_parr_ops_errors(self, ng, box_with_array):
idx = PeriodIndex(['2011-01', '2011-02', '2011-03', '2011-04'],
freq='M', name='idx')
@pytest.mark.parametrize("ng", ["str", 1.5])
@pytest.mark.parametrize("func", [
lambda obj, ng: obj + ng,
lambda obj, ng: ng + obj,
lambda obj, ng: obj - ng,
lambda obj, ng: ng - obj,
lambda obj, ng: np.add(obj, ng),
lambda obj, ng: np.add(ng, obj),
lambda obj, ng: np.subtract(obj, ng),
lambda obj, ng: np.subtract(ng, obj),
])
def test_parr_ops_errors(self, ng, func, box_with_array):
idx = PeriodIndex(["2011-01", "2011-02", "2011-03", "2011-04"],
freq="M", name="idx")
obj = tm.box_expected(idx, box_with_array)

msg = r"unsupported operand type\(s\)"
with pytest.raises(TypeError, match=msg):
obj + ng

with pytest.raises(TypeError):
# error message differs between PY2 and 3
ng + obj
msg = (r"unsupported operand type\(s\)|can only concatenate|"
r"must be str|object to str implicitly")

with pytest.raises(TypeError, match=msg):
obj - ng

with pytest.raises(TypeError):
np.add(obj, ng)

with pytest.raises(TypeError):
np.add(ng, obj)

with pytest.raises(TypeError):
np.subtract(obj, ng)

with pytest.raises(TypeError):
np.subtract(ng, obj)
func(obj, ng)

def test_pi_ops_nat(self):
idx = PeriodIndex(['2011-01', '2011-02', 'NaT', '2011-04'],
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/frame/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2581,11 +2581,9 @@ def test_boolean_indexing_mixed(self):
assert_frame_equal(df2, expected)

df['foo'] = 'test'
msg = ("boolean setting on mixed-type|"
"not supported between|"
"unorderable types")
msg = "not supported between instances|unorderable types"

with pytest.raises(TypeError, match=msg):
# TODO: This message should be the same in PY2/PY3
df[df > 0.3] = 1

def test_where(self):
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/series/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ def test_index_repr_in_frame_with_nan(self):
class TestCategoricalRepr(object):

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

class County(StringMixin):
name = u'San Sebastián'
Expand All @@ -214,7 +212,7 @@ class County(StringMixin):
def __unicode__(self):
return self.name + u', ' + self.state

cat = pd.Categorical([County() for n in range(61)])
cat = pd.Categorical([County() for _ in range(61)])
idx = pd.Index(cat)
ser = idx.to_series()

Expand Down