11
11
from shutil import get_terminal_size
12
12
import sys
13
13
import textwrap
14
- import warnings
15
14
16
15
import dateutil
17
16
import numpy as np
31
30
32
31
use_32bit_repr = is_platform_windows () or is_platform_32bit ()
33
32
34
- _frame = DataFrame (tm .getSeriesData ())
35
-
36
33
37
34
def curpath ():
38
35
pth , _ = os .path .split (os .path .abspath (__file__ ))
@@ -101,18 +98,9 @@ def has_expanded_repr(df):
101
98
return False
102
99
103
100
101
+ @pytest .mark .filterwarnings ('ignore::FutureWarning:.*format' )
104
102
class TestDataFrameFormatting :
105
103
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
-
116
104
def test_repr_embedded_ndarray (self ):
117
105
arr = np .empty (10 , dtype = [('err' , object )])
118
106
for i in range (len (arr )):
@@ -123,17 +111,18 @@ def test_repr_embedded_ndarray(self):
123
111
repr (df )
124
112
df .to_string ()
125
113
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
128
117
129
118
fmt .set_eng_float_format ()
130
- repr (self . frame )
119
+ repr (df )
131
120
132
121
fmt .set_eng_float_format (use_eng_prefix = True )
133
- repr (self . frame )
122
+ repr (df )
134
123
135
124
fmt .set_eng_float_format (accuracy = 0 )
136
- repr (self . frame )
125
+ repr (df )
137
126
tm .reset_display_options ()
138
127
139
128
def test_show_null_counts (self ):
@@ -467,7 +456,7 @@ def test_to_string_repr_unicode(self):
467
456
finally :
468
457
sys .stdin = _stdin
469
458
470
- def test_to_string_unicode_columns (self ):
459
+ def test_to_string_unicode_columns (self , float_frame ):
471
460
df = DataFrame ({'\u03c3 ' : np .arange (10. )})
472
461
473
462
buf = StringIO ()
@@ -478,7 +467,7 @@ def test_to_string_unicode_columns(self):
478
467
df .info (buf = buf )
479
468
buf .getvalue ()
480
469
481
- result = self . frame .to_string ()
470
+ result = float_frame .to_string ()
482
471
assert isinstance (result , str )
483
472
484
473
def test_to_string_utf8_columns (self ):
@@ -1513,14 +1502,15 @@ def test_show_dimensions(self):
1513
1502
assert '5 rows' not in str (df )
1514
1503
assert '5 rows' not in df ._repr_html_ ()
1515
1504
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_ ()
1518
1508
1519
1509
fmt .set_option ('display.max_rows' , 1 , 'display.max_columns' , 1 )
1520
- self . frame ._repr_html_ ()
1510
+ df ._repr_html_ ()
1521
1511
1522
1512
fmt .set_option ('display.notebook_repr_html' , False )
1523
- self . frame ._repr_html_ ()
1513
+ df ._repr_html_ ()
1524
1514
1525
1515
tm .reset_display_options ()
1526
1516
@@ -1698,16 +1688,18 @@ def test_info_repr_html(self):
1698
1688
'display.max_columns' , max_cols ):
1699
1689
assert '<class' in df ._repr_html_ ()
1700
1690
1701
- def test_fake_qtconsole_repr_html (self ):
1691
+ def test_fake_qtconsole_repr_html (self , float_frame ):
1692
+ df = float_frame
1693
+
1702
1694
def get_ipython ():
1703
1695
return {'config' : {'KernelApp' :
1704
1696
{'parent_appname' : 'ipython-qtconsole' }}}
1705
1697
1706
- repstr = self . frame ._repr_html_ ()
1698
+ repstr = df ._repr_html_ ()
1707
1699
assert repstr is not None
1708
1700
1709
1701
fmt .set_option ('display.max_rows' , 5 , 'display.max_columns' , 2 )
1710
- repstr = self . frame ._repr_html_ ()
1702
+ repstr = df ._repr_html_ ()
1711
1703
1712
1704
assert 'class' in repstr # info fallback
1713
1705
tm .reset_display_options ()
0 commit comments