Skip to content

Commit e935c70

Browse files
simonjayhawkinsjreback
authored andcommitted
TST/CLN: reuse float_frame fixture in tests\io\formats\test_format.py (#26756)
1 parent f8225bc commit e935c70

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

pandas/tests/io/formats/test_format.py

+19-27
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from shutil import get_terminal_size
1212
import sys
1313
import textwrap
14-
import warnings
1514

1615
import dateutil
1716
import numpy as np
@@ -31,8 +30,6 @@
3130

3231
use_32bit_repr = is_platform_windows() or is_platform_32bit()
3332

34-
_frame = DataFrame(tm.getSeriesData())
35-
3633

3734
def curpath():
3835
pth, _ = os.path.split(os.path.abspath(__file__))
@@ -101,18 +98,9 @@ def has_expanded_repr(df):
10198
return False
10299

103100

101+
@pytest.mark.filterwarnings('ignore::FutureWarning:.*format')
104102
class TestDataFrameFormatting:
105103

106-
def setup_method(self, method):
107-
self.warn_filters = warnings.filters
108-
warnings.filterwarnings('ignore', category=FutureWarning,
109-
module=".*format")
110-
111-
self.frame = _frame.copy()
112-
113-
def teardown_method(self, method):
114-
warnings.filters = self.warn_filters
115-
116104
def test_repr_embedded_ndarray(self):
117105
arr = np.empty(10, dtype=[('err', object)])
118106
for i in range(len(arr)):
@@ -123,17 +111,18 @@ def test_repr_embedded_ndarray(self):
123111
repr(df)
124112
df.to_string()
125113

126-
def test_eng_float_formatter(self):
127-
self.frame.loc[5] = 0
114+
def test_eng_float_formatter(self, float_frame):
115+
df = float_frame
116+
df.loc[5] = 0
128117

129118
fmt.set_eng_float_format()
130-
repr(self.frame)
119+
repr(df)
131120

132121
fmt.set_eng_float_format(use_eng_prefix=True)
133-
repr(self.frame)
122+
repr(df)
134123

135124
fmt.set_eng_float_format(accuracy=0)
136-
repr(self.frame)
125+
repr(df)
137126
tm.reset_display_options()
138127

139128
def test_show_null_counts(self):
@@ -467,7 +456,7 @@ def test_to_string_repr_unicode(self):
467456
finally:
468457
sys.stdin = _stdin
469458

470-
def test_to_string_unicode_columns(self):
459+
def test_to_string_unicode_columns(self, float_frame):
471460
df = DataFrame({'\u03c3': np.arange(10.)})
472461

473462
buf = StringIO()
@@ -478,7 +467,7 @@ def test_to_string_unicode_columns(self):
478467
df.info(buf=buf)
479468
buf.getvalue()
480469

481-
result = self.frame.to_string()
470+
result = float_frame.to_string()
482471
assert isinstance(result, str)
483472

484473
def test_to_string_utf8_columns(self):
@@ -1513,14 +1502,15 @@ def test_show_dimensions(self):
15131502
assert '5 rows' not in str(df)
15141503
assert '5 rows' not in df._repr_html_()
15151504

1516-
def test_repr_html(self):
1517-
self.frame._repr_html_()
1505+
def test_repr_html(self, float_frame):
1506+
df = float_frame
1507+
df._repr_html_()
15181508

15191509
fmt.set_option('display.max_rows', 1, 'display.max_columns', 1)
1520-
self.frame._repr_html_()
1510+
df._repr_html_()
15211511

15221512
fmt.set_option('display.notebook_repr_html', False)
1523-
self.frame._repr_html_()
1513+
df._repr_html_()
15241514

15251515
tm.reset_display_options()
15261516

@@ -1698,16 +1688,18 @@ def test_info_repr_html(self):
16981688
'display.max_columns', max_cols):
16991689
assert '<class' in df._repr_html_()
17001690

1701-
def test_fake_qtconsole_repr_html(self):
1691+
def test_fake_qtconsole_repr_html(self, float_frame):
1692+
df = float_frame
1693+
17021694
def get_ipython():
17031695
return {'config': {'KernelApp':
17041696
{'parent_appname': 'ipython-qtconsole'}}}
17051697

1706-
repstr = self.frame._repr_html_()
1698+
repstr = df._repr_html_()
17071699
assert repstr is not None
17081700

17091701
fmt.set_option('display.max_rows', 5, 'display.max_columns', 2)
1710-
repstr = self.frame._repr_html_()
1702+
repstr = df._repr_html_()
17111703

17121704
assert 'class' in repstr # info fallback
17131705
tm.reset_display_options()

0 commit comments

Comments
 (0)