Skip to content

Commit 8540826

Browse files
committed
write some tests
1 parent 9427864 commit 8540826

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

pandas/core/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,7 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
22252225
# kinds
22262226

22272227
@Appender(_shared_docs['reindex'] % dict(axes="axes", klass="NDFrame"))
2228-
def reindex(self, *args, **kwargs):
2228+
def reindex(self, *args, **kwargs):
22292229

22302230
# construct the args
22312231
axes, kwargs = self._construct_axes_from_arguments(args, kwargs)

pandas/sparse/list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pandas.formats.printing import pprint_thing
55

66
from pandas.types.common import is_scalar
7-
from pands.core.common import _enforce_bool_type
7+
from pandas.core.common import _enforce_bool_type
88
from pandas.sparse.array import SparseArray
99
import pandas._sparse as splib
1010

@@ -79,7 +79,7 @@ def consolidate(self, inplace=True):
7979
If inplace=False, new object, otherwise reference to existing
8080
object
8181
"""
82-
inplace = com.enforce_bool_type(inplace)
82+
inplace = _enforce_bool_type(inplace)
8383
if not inplace:
8484
result = self.copy()
8585
else:

pandas/tests/test_common.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,19 @@ def test_dict_compat():
198198
assert (com._dict_compat(data_unchanged) == data_unchanged)
199199

200200

201+
def test_enforce_bool_type():
202+
tm.assert_equal(com._enforce_bool_type(True), True)
203+
tm.assert_equal(com._enforce_bool_type(False), False)
204+
205+
error_str = "Expected type bool, received type int."
206+
with tm.assertRaisesRegexp(ValueError, error_str):
207+
com._enforce_bool_type(1)
208+
209+
error_str = "Expected type bool, received type str."
210+
with tm.assertRaisesRegexp(ValueError, error_str):
211+
com._enforce_bool_type("True")
212+
213+
201214
if __name__ == '__main__':
202215
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
203216
exit=False)

0 commit comments

Comments
 (0)