8
8
DataFrame ,
9
9
Series ,
10
10
)
11
- import pandas ._testing as tm
12
11
13
12
pytest .importorskip ("jinja2" )
14
13
@@ -30,27 +29,27 @@ def df_short():
30
29
31
30
32
31
class TestToLatex :
33
- def test_to_latex_to_file (self , float_frame ):
34
- with tm . ensure_clean ( "test.tex" ) as path :
35
- float_frame .to_latex (path )
36
- with open (path , encoding = "utf-8" ) as f :
37
- assert float_frame .to_latex () == f .read ()
32
+ def test_to_latex_to_file (self , float_frame , temp_file ):
33
+ path = str ( temp_file )
34
+ float_frame .to_latex (path )
35
+ with open (path , encoding = "utf-8" ) as f :
36
+ assert float_frame .to_latex () == f .read ()
38
37
39
- def test_to_latex_to_file_utf8_with_encoding (self ):
38
+ def test_to_latex_to_file_utf8_with_encoding (self , temp_file ):
40
39
# test with utf-8 and encoding option (GH 7061)
41
40
df = DataFrame ([["au\xdf gangen" ]])
42
- with tm . ensure_clean ( "test.tex" ) as path :
43
- df .to_latex (path , encoding = "utf-8" )
44
- with open (path , encoding = "utf-8" ) as f :
45
- assert df .to_latex () == f .read ()
41
+ path = str ( temp_file )
42
+ df .to_latex (path , encoding = "utf-8" )
43
+ with open (path , encoding = "utf-8" ) as f :
44
+ assert df .to_latex () == f .read ()
46
45
47
- def test_to_latex_to_file_utf8_without_encoding (self ):
46
+ def test_to_latex_to_file_utf8_without_encoding (self , temp_file ):
48
47
# test with utf-8 without encoding option
49
48
df = DataFrame ([["au\xdf gangen" ]])
50
- with tm . ensure_clean ( "test.tex" ) as path :
51
- df .to_latex (path )
52
- with open (path , encoding = "utf-8" ) as f :
53
- assert df .to_latex () == f .read ()
49
+ path = str ( temp_file )
50
+ df .to_latex (path )
51
+ with open (path , encoding = "utf-8" ) as f :
52
+ assert df .to_latex () == f .read ()
54
53
55
54
def test_to_latex_tabular_with_index (self ):
56
55
df = DataFrame ({"a" : [1 , 2 ], "b" : ["b1" , "b2" ]})
0 commit comments