Repository: pandas-dev/pandas

Issue:
COMPAT: remove pandas line_width/height deprecations from test suite
https://travis-ci.org/jreback/pandas/jobs/23875619

if deprecations mode is turned on #6960 then these become apparant

I think the tests simply need to be change and/or asserted that these are actually producing deprecation warnings



Discussion:
@jorisvandenbossche a couple of minor sql deprecation warnings that should prob be caught / tested


Resolving patch:
diff --git a/pandas/core/config.py b/pandas/core/config.py
--- a/pandas/core/config.py
+++ b/pandas/core/config.py
@@ -140,7 +140,7 @@ def _describe_option(pat='', _print_desc=True):
         return s
 
 
-def _reset_option(pat):
+def _reset_option(pat, silent=False):
 
     keys = _select_options(pat)
 
@@ -154,7 +154,7 @@ def _reset_option(pat):
                          'value')
 
     for k in keys:
-        _set_option(k, _registered_options[k].defval)
+        _set_option(k, _registered_options[k].defval, silent=silent)
 
 
 def get_default_val(pat):
@@ -361,7 +361,7 @@ def __enter__(self):
     def __exit__(self, *args):
         if self.undo:
             for pat, val in self.undo:
-                _set_option(pat, val)
+                _set_option(pat, val, silent=True)
 
 
 def register_option(key, defval, doc='', validator=None, cb=None):
@@ -567,6 +567,7 @@ def _warn_if_deprecated(key):
     d = _get_deprecated_option(key)
     if d:
         if d.msg:
+            print(d.msg)
             warnings.warn(d.msg, DeprecationWarning)
         else:
             msg = "'%s' is deprecated" % key


Test patch:
diff --git a/pandas/tests/test_format.py b/pandas/tests/test_format.py
--- a/pandas/tests/test_format.py
+++ b/pandas/tests/test_format.py
@@ -104,8 +104,7 @@ def test_eng_float_formatter(self):
 
         fmt.set_eng_float_format(accuracy=0)
         repr(self.frame)
-
-        fmt.reset_option('^display.')
+        self.reset_display_options()
 
     def test_repr_tuples(self):
         buf = StringIO()
@@ -1034,7 +1033,7 @@ def test_to_string_no_index(self):
         assert(df_s == expected)
 
     def test_to_string_float_formatting(self):
-        fmt.reset_option('^display.')
+        self.reset_display_options()
         fmt.set_option('display.precision', 6, 'display.column_space',
                        12, 'display.notebook_repr_html', False)
 
@@ -1065,7 +1064,7 @@ def test_to_string_float_formatting(self):
                     '1     0.253')
         assert(df_s == expected)
 
-        fmt.reset_option('^display.')
+        self.reset_display_options()
         self.assertEqual(get_option("display.precision"), 7)
 
         df = DataFrame({'x': [1e9, 0.2512]})
@@ -1157,7 +1156,7 @@ def test_to_string_index_formatter(self):
         self.assertEqual(rs, xp)
 
     def test_to_string_left_justify_cols(self):
-        fmt.reset_option('^display.')
+        self.reset_display_options()
         df = DataFrame({'x': [3234, 0.253]})
         df_s = df.to_string(justify='left')
         expected = ('   x       \n'
@@ -1166,7 +1165,7 @@ def test_to_string_left_justify_cols(self):
         assert(df_s == expected)
 
     def test_to_string_format_na(self):
-        fmt.reset_option('^display.')
+        self.reset_display_options()
         df = DataFrame({'A': [np.nan, -1, -2.1234, 3, 4],
                         'B': [np.nan, 'foo', 'foooo', 'fooooo', 'bar']})
         result = df.to_string()
@@ -1434,14 +1433,14 @@ def test_repr_html(self):
         fmt.set_option('display.notebook_repr_html', False)
         self.frame._repr_html_()
 
-        fmt.reset_option('^display.')
+        self.reset_display_options()
 
         df = DataFrame([[1, 2], [3, 4]])
         self.assertTrue('2 rows' in df._repr_html_())
         fmt.set_option('display.show_dimensions', False)
         self.assertFalse('2 rows' in df._repr_html_())
 
-        fmt.reset_option('^display.')
+        self.reset_display_options()
 
     def test_repr_html_wide(self):
         row = lambda l, k: [tm.rands(k) for _ in range(l)]
@@ -1580,7 +1579,7 @@ def get_ipython():
         repstr = self.frame._repr_html_()
         self.assertIn('class', repstr)  # info fallback
 
-        fmt.reset_option('^display.')
+        self.reset_display_options()
 
     def test_to_html_with_classes(self):
         df = pandas.DataFrame()
@@ -2092,7 +2091,7 @@ def test_eng_float_formatter(self):
                     '3    1E+06')
         self.assertEqual(result, expected)
 
-        fmt.reset_option('^display.')
+        self.reset_display_options()
 
     def compare(self, formatter, input, output):
         formatted_input = formatter(input)
diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py
--- a/pandas/tests/test_frame.py
+++ b/pandas/tests/test_frame.py
@@ -4355,7 +4355,7 @@ def test_repr_dimensions(self):
         fmt.set_option('display.show_dimensions', False)
         self.assertFalse("2 rows x 2 columns" in repr(df))
 
-        fmt.reset_option('^display\.')
+        self.reset_display_options()
 
     @slow
     def test_repr_big(self):
@@ -4391,7 +4391,7 @@ def test_repr_unsortable(self):
         fmt.set_option('display.max_rows', 1000, 'display.max_columns', 1000)
         repr(self.frame)
 
-        fmt.reset_option('^display\.')
+        self.reset_display_options()
 
         warnings.filters = warn_filters
 
diff --git a/pandas/tests/test_index.py b/pandas/tests/test_index.py
--- a/pandas/tests/test_index.py
+++ b/pandas/tests/test_index.py
@@ -2145,7 +2145,7 @@ def test_format_sparse_config(self):
         result = self.index.format()
         self.assertEqual(result[1], 'foo  two')
 
-        pd.reset_option("^display\.")
+        self.reset_display_options()
 
         warnings.filters = warn_filters
 
diff --git a/pandas/util/testing.py b/pandas/util/testing.py
--- a/pandas/util/testing.py
+++ b/pandas/util/testing.py
@@ -69,6 +69,10 @@ def setUpClass(cls):
     def tearDownClass(cls):
         pass
 
+    def reset_display_options(self):
+        # reset the display options
+        pd.reset_option('^display.',silent=True)
+
     def assert_numpy_array_equal(self, np_array, assert_equal):
         if np.array_equal(np_array, assert_equal):
 	        return