Skip to content

TST: Fix test assertions #16470

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
May 24, 2017
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
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_nth.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def test_nth(self):
expected = s.groupby(g).first()
expected2 = s.groupby(g).apply(lambda x: x.iloc[0])
assert_series_equal(expected2, expected, check_names=False)
assert expected.name, 0
assert expected.name == 1
assert expected2.name == 1

# validate first
v = s[g == 1].iloc[0]
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def test_to_datetime_iso8601(self):
def test_to_datetime_default(self):
rs = to_datetime('2001')
xp = datetime(2001, 1, 1)
assert rs, xp
assert rs == xp

# dayfirst is essentially broken

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexes/period/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ def test_constructor_fromarraylike(self):

result = PeriodIndex(idx, freq=offsets.MonthEnd())
tm.assert_index_equal(result, idx)
assert result.freq, 'M'
assert result.freq == 'M'

result = PeriodIndex(idx, freq='2M')
tm.assert_index_equal(result, idx.asfreq('2M'))
assert result.freq, '2M'
assert result.freq == '2M'

result = PeriodIndex(idx, freq=offsets.MonthEnd(2))
tm.assert_index_equal(result, idx.asfreq('2M'))
assert result.freq, '2M'
assert result.freq == '2M'

result = PeriodIndex(idx, freq='D')
exp = idx.asfreq('D', 'e')
Expand Down
14 changes: 7 additions & 7 deletions pandas/tests/indexes/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ def test_constructor_name(self):
copy = RangeIndex(orig)
copy.name = 'copy'

assert orig.name, 'original'
assert copy.name, 'copy'
assert orig.name == 'original'
assert copy.name == 'copy'

new = Index(copy)
assert new.name, 'copy'
assert new.name == 'copy'

new.name = 'new'
assert orig.name, 'original'
assert new.name, 'copy'
assert new.name, 'new'
assert orig.name == 'original'
assert copy.name == 'copy'
assert new.name == 'new'

def test_numeric_compat2(self):
# validate that we are handling the RangeIndex overrides to numeric ops
Expand Down Expand Up @@ -273,7 +273,7 @@ def test_repr(self):
expected = "RangeIndex(start=0, stop=5, step=1, name='Foo')"
else:
expected = "RangeIndex(start=0, stop=5, step=1, name=u'Foo')"
assert result, expected
assert result == expected

result = eval(result)
tm.assert_index_equal(result, i, exact=True)
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ def test_to_weekly_resampling(self):
tsplot(high, plt.Axes.plot)
lines = tsplot(low, plt.Axes.plot)
for l in lines:
assert PeriodIndex(data=l.get_xdata()).freq, idxh.freq
assert PeriodIndex(data=l.get_xdata()).freq == idxh.freq

@slow
def test_from_weekly_resampling(self):
Expand All @@ -858,7 +858,7 @@ def test_from_weekly_resampling(self):
expected_l = np.array([1514, 1519, 1523, 1527, 1531, 1536, 1540, 1544,
1549, 1553, 1558, 1562], dtype=np.float64)
for l in ax.get_lines():
assert PeriodIndex(data=l.get_xdata()).freq, idxh.freq
assert PeriodIndex(data=l.get_xdata()).freq == idxh.freq
xdata = l.get_xdata(orig=False)
if len(xdata) == 12: # idxl lines
tm.assert_numpy_array_equal(xdata, expected_l)
Expand All @@ -873,7 +873,7 @@ def test_from_weekly_resampling(self):
tsplot(low, plt.Axes.plot)
lines = tsplot(high, plt.Axes.plot)
for l in lines:
assert PeriodIndex(data=l.get_xdata()).freq, idxh.freq
assert PeriodIndex(data=l.get_xdata()).freq == idxh.freq
xdata = l.get_xdata(orig=False)
if len(xdata) == 12: # idxl lines
tm.assert_numpy_array_equal(xdata, expected_l)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def test_from_M8_structured(self):
assert df['Forecasting'][0] == dates[0][1]

s = Series(arr['Date'])
assert s[0], Timestamp
assert isinstance(s[0], Timestamp)
assert s[0] == dates[0][0]

s = Series.from_array(arr['Date'], Index([0]))
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class TestMisc(object):
def test_max_len_string_array(self):

arr = a = np.array(['foo', 'b', np.nan], dtype='object')
assert lib.max_len_string_array(arr), 3
assert lib.max_len_string_array(arr) == 3

# unicode
arr = a.astype('U').astype(object)
assert lib.max_len_string_array(arr), 3
assert lib.max_len_string_array(arr) == 3

# bytes for python3
arr = a.astype('S').astype(object)
assert lib.max_len_string_array(arr), 3
assert lib.max_len_string_array(arr) == 3

# raises
pytest.raises(TypeError,
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2102,12 +2102,12 @@ def test_split_with_name(self):
idx = Index(['a,b', 'c,d'], name='xxx')
res = idx.str.split(',')
exp = Index([['a', 'b'], ['c', 'd']], name='xxx')
assert res.nlevels, 1
assert res.nlevels == 1
tm.assert_index_equal(res, exp)

res = idx.str.split(',', expand=True)
exp = MultiIndex.from_tuples([('a', 'b'), ('c', 'd')])
assert res.nlevels, 2
assert res.nlevels == 2
tm.assert_index_equal(res, exp)

def test_partition_series(self):
Expand Down Expand Up @@ -2247,13 +2247,13 @@ def test_partition_with_name(self):
idx = Index(['a,b', 'c,d'], name='xxx')
res = idx.str.partition(',')
exp = MultiIndex.from_tuples([('a', ',', 'b'), ('c', ',', 'd')])
assert res.nlevels, 3
assert res.nlevels == 3
tm.assert_index_equal(res, exp)

# should preserve name
res = idx.str.partition(',', expand=False)
exp = Index(np.array([('a', ',', 'b'), ('c', ',', 'd')]), name='xxx')
assert res.nlevels, 1
assert res.nlevels == 1
tm.assert_index_equal(res, exp)

def test_pipe_failures(self):
Expand Down