Skip to content

Commit

Permalink
test for warning
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Nov 9, 2018
1 parent ace62aa commit 6e76b51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ def formatting_values(self):
"'ExtensionArray._formatting_values' is deprecated. "
"Specify 'ExtensionArray._formatter' instead."
)
warnings.warn(msg, FutureWarning)
warnings.warn(msg, FutureWarning, stacklevel=10)
return self.values._formatting_values()

# the future implementation (and current, if not overrode)
Expand Down
14 changes: 13 additions & 1 deletion pandas/tests/extension/decimal/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ class TestSetitem(BaseDecimal, base.BaseSetitemTests):


class TestPrinting(BaseDecimal, base.BasePrintingTests):
pass
pytestmark = pytest.mark.skipif(compat.PY2,
reason="Unhashble dtype in Py2.")


# TODO(extension)
Expand Down Expand Up @@ -384,3 +385,14 @@ def test_divmod_array(reverse, expected_div, expected_mod):

tm.assert_extension_array_equal(div, expected_div)
tm.assert_extension_array_equal(mod, expected_mod)


def test_formatting_values_deprecated():
class DecimalArray2(DecimalArray):
def _formatting_values(self):
return np.array(self)

ser = pd.Series(DecimalArray2([decimal.Decimal('1.0')]))

with tm.assert_produces_warning(FutureWarning):
repr(ser)

0 comments on commit 6e76b51

Please sign in to comment.