Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
TST: test custom _formatter for ExtensionArray
  • Loading branch information
jorisvandenbossche committed Jun 14, 2019
commit 7a8ceeff55d8ba7f45ad704854c1ec290941bb8d
5 changes: 5 additions & 0 deletions pandas/tests/extension/decimal/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ def isna(self):
def _na_value(self):
return decimal.Decimal('NaN')

def _formatter(self, boxed=False):
if boxed:
return "Decimal: {0}".format
return repr

@classmethod
def _concat_same_type(cls, to_concat):
return cls(np.concatenate([x._data for x in to_concat]))
Expand Down
8 changes: 7 additions & 1 deletion pandas/tests/extension/decimal/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ class TestSetitem(BaseDecimal, base.BaseSetitemTests):


class TestPrinting(BaseDecimal, base.BasePrintingTests):
pass

def test_series_repr(self, data):
# Overriding this base test to explicitly test that
# the custom _formatter is used
ser = pd.Series(data)
assert data.dtype.name in repr(ser)
assert "Decimal: " in repr(ser)


# TODO(extension)
Expand Down