Skip to content

Commit ded42ea

Browse files
author
Roger Thomas
committed
Update
1 parent 6ecc984 commit ded42ea

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/tests/frame/test_analytics.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1985,11 +1985,15 @@ def test_n_error(self, df_strings):
19851985
columns_with_errors = {'category_string', 'string'}
19861986
columns_without_errors = list(set(df) - columns_with_errors)
19871987
for column in columns_with_errors:
1988+
dtype = df[column].dtype
19881989
for columns in (column, ['group', column]):
1989-
with pytest.raises(TypeError):
1990+
msg_template = "Cannot use method '%s' with dtype %s"
1991+
with pytest.raises(TypeError) as exc_info:
19901992
df.nsmallest(2, columns)
1991-
with pytest.raises(TypeError):
1993+
assert exc_info.value, msg_template % ('nsmallest', dtype)
1994+
with pytest.raises(TypeError) as exc_info:
19921995
df.nlargest(2, columns)
1996+
assert exc_info.value, msg_template % ('nlargest', dtype)
19931997
df.nsmallest(2, columns_without_errors)
19941998
df.nsmallest(2, ['int', 'string']) # int column is unique => OK
19951999

0 commit comments

Comments
 (0)