Skip to content

Commit 6e1e851

Browse files
committed
test_to_latex updated
1 parent 0742698 commit 6e1e851

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

pandas/tests/io/formats/test_to_latex.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
DataFrame,
99
Series,
1010
)
11-
import pandas._testing as tm
1211

1312
pytest.importorskip("jinja2")
1413

@@ -30,27 +29,27 @@ def df_short():
3029

3130

3231
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()
3837

39-
def test_to_latex_to_file_utf8_with_encoding(self):
38+
def test_to_latex_to_file_utf8_with_encoding(self, temp_file):
4039
# test with utf-8 and encoding option (GH 7061)
4140
df = DataFrame([["au\xdfgangen"]])
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()
4645

47-
def test_to_latex_to_file_utf8_without_encoding(self):
46+
def test_to_latex_to_file_utf8_without_encoding(self, temp_file):
4847
# test with utf-8 without encoding option
4948
df = DataFrame([["au\xdfgangen"]])
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()
5453

5554
def test_to_latex_tabular_with_index(self):
5655
df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]})

0 commit comments

Comments
 (0)