Skip to content

Commit 7a8ceef

Browse files
TST: test custom _formatter for ExtensionArray
1 parent 2d2606d commit 7a8ceef

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/tests/extension/decimal/array.py

+5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ def isna(self):
137137
def _na_value(self):
138138
return decimal.Decimal('NaN')
139139

140+
def _formatter(self, boxed=False):
141+
if boxed:
142+
return "Decimal: {0}".format
143+
return repr
144+
140145
@classmethod
141146
def _concat_same_type(cls, to_concat):
142147
return cls(np.concatenate([x._data for x in to_concat]))

pandas/tests/extension/decimal/test_decimal.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ class TestSetitem(BaseDecimal, base.BaseSetitemTests):
200200

201201

202202
class TestPrinting(BaseDecimal, base.BasePrintingTests):
203-
pass
203+
204+
def test_series_repr(self, data):
205+
# Overriding this base test to explicitly test that
206+
# the custom _formatter is used
207+
ser = pd.Series(data)
208+
assert data.dtype.name in repr(ser)
209+
assert "Decimal: " in repr(ser)
204210

205211

206212
# TODO(extension)

0 commit comments

Comments
 (0)