test_warnings.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. import pytest
  3. import pandas as pd
  4. import pandas.util.testing as tm
  5. class TestCategoricalWarnings(object):
  6. def test_tab_complete_warning(self, ip):
  7. # https://github.com/pandas-dev/pandas/issues/16409
  8. pytest.importorskip('IPython', minversion="6.0.0")
  9. from IPython.core.completer import provisionalcompleter
  10. code = "import pandas as pd; c = Categorical([])"
  11. ip.run_code(code)
  12. with tm.assert_produces_warning(None):
  13. with provisionalcompleter('ignore'):
  14. list(ip.Completer.completions('c.', 1))
  15. def test_CategoricalAccessor_categorical_deprecation(object):
  16. with tm.assert_produces_warning(FutureWarning):
  17. pd.Series(['a', 'b'], dtype='category').cat.categorical
  18. def test_CategoricalAccessor_name_deprecation(object):
  19. with tm.assert_produces_warning(FutureWarning):
  20. pd.Series(['a', 'b'], dtype='category').cat.name
  21. def test_CategoricalAccessor_index_deprecation(object):
  22. with tm.assert_produces_warning(FutureWarning):
  23. pd.Series(['a', 'b'], dtype='category').cat.index