Skip to content

Commit 615712c

Browse files
committed
MAINT: Move reset_display_options outside of TestCase
1 parent 3119e90 commit 615712c

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

pandas/tests/formats/test_eng_formatting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_eng_float_formatter(self):
3838
'3 1E+06')
3939
self.assertEqual(result, expected)
4040

41-
self.reset_display_options()
41+
tm.reset_display_options()
4242

4343
def compare(self, formatter, input, output):
4444
formatted_input = formatter(input)
@@ -185,7 +185,7 @@ def test_nan(self):
185185
fmt.set_eng_float_format(accuracy=1)
186186
result = pt.to_string()
187187
self.assertTrue('NaN' in result)
188-
self.reset_display_options()
188+
tm.reset_display_options()
189189

190190
def test_inf(self):
191191
# Issue #11981

pandas/tests/formats/test_format.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_eng_float_formatter(self):
138138

139139
fmt.set_eng_float_format(accuracy=0)
140140
repr(self.frame)
141-
self.reset_display_options()
141+
tm.reset_display_options()
142142

143143
def test_show_null_counts(self):
144144

@@ -1197,7 +1197,7 @@ def test_to_string_line_width_no_index(self):
11971197
self.assertEqual(df_s, expected)
11981198

11991199
def test_to_string_float_formatting(self):
1200-
self.reset_display_options()
1200+
tm.reset_display_options()
12011201
fmt.set_option('display.precision', 5, 'display.column_space', 12,
12021202
'display.notebook_repr_html', False)
12031203

@@ -1226,7 +1226,7 @@ def test_to_string_float_formatting(self):
12261226
expected = (' x\n' '0 3234.000\n' '1 0.253')
12271227
self.assertEqual(df_s, expected)
12281228

1229-
self.reset_display_options()
1229+
tm.reset_display_options()
12301230
self.assertEqual(get_option("display.precision"), 6)
12311231

12321232
df = DataFrame({'x': [1e9, 0.2512]})
@@ -1310,14 +1310,14 @@ def test_to_string_index_formatter(self):
13101310
self.assertEqual(rs, xp)
13111311

13121312
def test_to_string_left_justify_cols(self):
1313-
self.reset_display_options()
1313+
tm.reset_display_options()
13141314
df = DataFrame({'x': [3234, 0.253]})
13151315
df_s = df.to_string(justify='left')
13161316
expected = (' x \n' '0 3234.000\n' '1 0.253')
13171317
self.assertEqual(df_s, expected)
13181318

13191319
def test_to_string_format_na(self):
1320-
self.reset_display_options()
1320+
tm.reset_display_options()
13211321
df = DataFrame({'A': [np.nan, -1, -2.1234, 3, 4],
13221322
'B': [np.nan, 'foo', 'foooo', 'fooooo', 'bar']})
13231323
result = df.to_string()
@@ -1380,15 +1380,15 @@ def test_repr_html(self):
13801380
fmt.set_option('display.notebook_repr_html', False)
13811381
self.frame._repr_html_()
13821382

1383-
self.reset_display_options()
1383+
tm.reset_display_options()
13841384

13851385
df = DataFrame([[1, 2], [3, 4]])
13861386
fmt.set_option('display.show_dimensions', True)
13871387
self.assertTrue('2 rows' in df._repr_html_())
13881388
fmt.set_option('display.show_dimensions', False)
13891389
self.assertFalse('2 rows' in df._repr_html_())
13901390

1391-
self.reset_display_options()
1391+
tm.reset_display_options()
13921392

13931393
def test_repr_html_wide(self):
13941394
max_cols = get_option('display.max_columns')
@@ -1552,7 +1552,7 @@ def get_ipython():
15521552
repstr = self.frame._repr_html_()
15531553
self.assertIn('class', repstr) # info fallback
15541554

1555-
self.reset_display_options()
1555+
tm.reset_display_options()
15561556

15571557
def test_pprint_pathological_object(self):
15581558
"""

pandas/tests/frame/test_repr_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def test_repr_unsortable(self):
118118
fmt.set_option('display.max_rows', 1000, 'display.max_columns', 1000)
119119
repr(self.frame)
120120

121-
self.reset_display_options()
121+
tm.reset_display_options()
122122

123123
warnings.filters = warn_filters
124124

pandas/tests/indexes/test_multi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ def test_format_sparse_config(self):
13921392
result = self.index.format()
13931393
self.assertEqual(result[1], 'foo two')
13941394

1395-
self.reset_display_options()
1395+
tm.reset_display_options()
13961396

13971397
warnings.filters = warn_filters
13981398

pandas/util/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def deprecate_kwarg(old_arg_name, new_arg_name, mapping=None, stacklevel=2):
2424
old_arg_name : str
2525
Name of argument in function to deprecate
2626
new_arg_name : str
27-
Name of prefered argument in function
27+
Name of preferred argument in function
2828
mapping : dict or callable
2929
If mapping is present, use it to translate old arguments to
3030
new arguments. A callable must do its own value checking;

pandas/util/testing.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ def setUpClass(cls):
9292
def tearDownClass(cls):
9393
pass
9494

95-
def reset_display_options(self):
96-
# reset the display options
97-
pd.reset_option('^display.', silent=True)
98-
9995
def round_trip_pickle(self, obj, path=None):
10096
return round_trip_pickle(obj, path=path)
10197

@@ -121,6 +117,14 @@ def assertNotAlmostEquals(self, *args, **kwargs):
121117
self.assertNotAlmostEqual)(*args, **kwargs)
122118

123119

120+
def reset_display_options():
121+
"""
122+
Reset the display options for printing and representing objects.
123+
"""
124+
125+
pd.reset_option('^display.', silent=True)
126+
127+
124128
def round_trip_pickle(obj, path=None):
125129
if path is None:
126130
path = u('__%s__.pickle' % rands(10))

0 commit comments

Comments
 (0)