Skip to content

Commit

Permalink
Merge branch 'add_more_error_tests' into fix_nsmallest_nlargest_with_…
Browse files Browse the repository at this point in the history
…n_identical_values
  • Loading branch information
Roger Thomas committed Apr 5, 2017
2 parents 3840771 + a5ce1b9 commit 75ac0b7
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1966,13 +1966,9 @@ def test_n(self, df_strings, method, n, order):

# Only expect error when 'b' is first in order, as 'a' and 'c' are
# unique
error_msg = (
"'b' has dtype: object, cannot use method 'nsmallest' "
"with this dtype"
)
with pytest.raises(TypeError) as exc_info:
error_msg = "Cannot use method '%s' with dtype object" % method
with tm.assertRaisesRegexp(TypeError, error_msg):
getattr(df, method)(n, order)
assert exc_info.value, error_msg
else:
ascending = method == 'nsmallest'
result = getattr(df, method)(n, order)
Expand All @@ -1986,12 +1982,11 @@ def test_n(self, df_strings, method, n, order):
))
def test_n_error(self, df_main_dtypes, method, columns):
df = df_main_dtypes
with pytest.raises(TypeError) as exc_info:
msg = "Cannot use method '%s' with dtype %s" % (
method, df[columns[1]].dtype
)
with tm.assertRaisesRegexp(TypeError, msg):
getattr(df, method)(2, columns)
msg = "Cannot use method '%s' with dtype %s" % (
method, df[columns[1]].dtype
)
assert exc_info.value, msg

def test_n_all_dtypes(self, df_main_dtypes):
df = df_main_dtypes
Expand Down

0 comments on commit 75ac0b7

Please sign in to comment.