|
| 1 | +import re |
| 2 | + |
1 | 3 | import numpy as np
|
2 | 4 | import pytest
|
3 | 5 |
|
@@ -30,7 +32,8 @@ def effective_dtype(self, dtype):
|
30 | 32 | return dtype
|
31 | 33 |
|
32 | 34 | def test_get_dummies_raises_on_dtype_object(self, df):
|
33 |
| - with pytest.raises(ValueError): |
| 35 | + msg = "dtype=object is not a valid dtype for get_dummies" |
| 36 | + with pytest.raises(ValueError, match=msg): |
34 | 37 | get_dummies(df, dtype="object")
|
35 | 38 |
|
36 | 39 | def test_get_dummies_basic(self, sparse, dtype):
|
@@ -296,11 +299,19 @@ def test_dataframe_dummies_prefix_sep(self, df, sparse):
|
296 | 299 | tm.assert_frame_equal(result, expected)
|
297 | 300 |
|
298 | 301 | def test_dataframe_dummies_prefix_bad_length(self, df, sparse):
|
299 |
| - with pytest.raises(ValueError): |
| 302 | + msg = re.escape( |
| 303 | + "Length of 'prefix' (1) did not match the length of the columns being " |
| 304 | + "encoded (2)" |
| 305 | + ) |
| 306 | + with pytest.raises(ValueError, match=msg): |
300 | 307 | get_dummies(df, prefix=["too few"], sparse=sparse)
|
301 | 308 |
|
302 | 309 | def test_dataframe_dummies_prefix_sep_bad_length(self, df, sparse):
|
303 |
| - with pytest.raises(ValueError): |
| 310 | + msg = re.escape( |
| 311 | + "Length of 'prefix_sep' (1) did not match the length of the columns being " |
| 312 | + "encoded (2)" |
| 313 | + ) |
| 314 | + with pytest.raises(ValueError, match=msg): |
304 | 315 | get_dummies(df, prefix_sep=["bad"], sparse=sparse)
|
305 | 316 |
|
306 | 317 | def test_dataframe_dummies_prefix_dict(self, sparse):
|
|
0 commit comments