diff --git a/pandas/conftest.py b/pandas/conftest.py index 8f71028f51ab4..09fe8e0829fa1 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -12,6 +12,8 @@ import pandas.util._test_decorators as td import pandas as pd +from pandas import DataFrame +import pandas.util.testing as tm hypothesis.settings.register_profile( "ci", @@ -690,3 +692,32 @@ def tick_classes(request): normalize=st.booleans(), startingMonth=st.integers(min_value=1, max_value=12) )) + + +@pytest.fixture +def float_frame(): + """ + Fixture for DataFrame of floats with index of unique strings + + Columns are ['A', 'B', 'C', 'D']. + + A B C D + P7GACiRnxd -0.465578 -0.361863 0.886172 -0.053465 + qZKh6afn8n -0.466693 -0.373773 0.266873 1.673901 + tkp0r6Qble 0.148691 -0.059051 0.174817 1.598433 + wP70WOCtv8 0.133045 -0.581994 -0.992240 0.261651 + M2AeYQMnCz -1.207959 -0.185775 0.588206 0.563938 + QEPzyGDYDo -0.381843 -0.758281 0.502575 -0.565053 + r78Jwns6dn -0.653707 0.883127 0.682199 0.206159 + ... ... ... ... ... + IHEGx9NO0T -0.277360 0.113021 -1.018314 0.196316 + lPMj8K27FA -1.313667 -0.604776 -1.305618 -0.863999 + qa66YMWQa5 1.110525 0.475310 -0.747865 0.032121 + yOa0ATsmcE -0.431457 0.067094 0.096567 -0.264962 + 65znX3uRNG 1.528446 0.160416 -0.109635 -0.032987 + eCOBvKqf3e 0.235281 1.622222 0.781255 0.392871 + xSucinXxuV -1.263557 0.252799 -0.552247 0.400426 + + [30 rows x 4 columns] + """ + return DataFrame(tm.getSeriesData()) diff --git a/pandas/tests/frame/conftest.py b/pandas/tests/frame/conftest.py index c451cd58f1497..d8a590bc492a4 100644 --- a/pandas/tests/frame/conftest.py +++ b/pandas/tests/frame/conftest.py @@ -5,35 +5,6 @@ import pandas.util.testing as tm -@pytest.fixture -def float_frame(): - """ - Fixture for DataFrame of floats with index of unique strings - - Columns are ['A', 'B', 'C', 'D']. - - A B C D - P7GACiRnxd -0.465578 -0.361863 0.886172 -0.053465 - qZKh6afn8n -0.466693 -0.373773 0.266873 1.673901 - tkp0r6Qble 0.148691 -0.059051 0.174817 1.598433 - wP70WOCtv8 0.133045 -0.581994 -0.992240 0.261651 - M2AeYQMnCz -1.207959 -0.185775 0.588206 0.563938 - QEPzyGDYDo -0.381843 -0.758281 0.502575 -0.565053 - r78Jwns6dn -0.653707 0.883127 0.682199 0.206159 - ... ... ... ... ... - IHEGx9NO0T -0.277360 0.113021 -1.018314 0.196316 - lPMj8K27FA -1.313667 -0.604776 -1.305618 -0.863999 - qa66YMWQa5 1.110525 0.475310 -0.747865 0.032121 - yOa0ATsmcE -0.431457 0.067094 0.096567 -0.264962 - 65znX3uRNG 1.528446 0.160416 -0.109635 -0.032987 - eCOBvKqf3e 0.235281 1.622222 0.781255 0.392871 - xSucinXxuV -1.263557 0.252799 -0.552247 0.400426 - - [30 rows x 4 columns] - """ - return DataFrame(tm.getSeriesData()) - - @pytest.fixture def float_frame_with_na(): """ diff --git a/pandas/tests/io/formats/test_to_latex.py b/pandas/tests/io/formats/test_to_latex.py index 5a6511fbd20ee..b9f28ec36d021 100644 --- a/pandas/tests/io/formats/test_to_latex.py +++ b/pandas/tests/io/formats/test_to_latex.py @@ -8,19 +8,14 @@ from pandas.util import testing as tm -@pytest.fixture -def frame(): - return DataFrame(tm.getSeriesData()) - - class TestToLatex: - def test_to_latex_filename(self, frame): + def test_to_latex_filename(self, float_frame): with tm.ensure_clean('test.tex') as path: - frame.to_latex(path) + float_frame.to_latex(path) with open(path, 'r') as f: - assert frame.to_latex() == f.read() + assert float_frame.to_latex() == f.read() # test with utf-8 and encoding option (GH 7061) df = DataFrame([['au\xdfgangen']]) @@ -35,9 +30,9 @@ def test_to_latex_filename(self, frame): with codecs.open(path, 'r', encoding='utf-8') as f: assert df.to_latex() == f.read() - def test_to_latex(self, frame): + def test_to_latex(self, float_frame): # it works! - frame.to_latex() + float_frame.to_latex() df = DataFrame({'a': [1, 2], 'b': ['b1', 'b2']}) withindex_result = df.to_latex() @@ -66,9 +61,9 @@ def test_to_latex(self, frame): assert withoutindex_result == withoutindex_expected - def test_to_latex_format(self, frame): + def test_to_latex_format(self, float_frame): # GH Bug #9402 - frame.to_latex(column_format='ccc') + float_frame.to_latex(column_format='ccc') df = DataFrame({'a': [1, 2], 'b': ['b1', 'b2']}) withindex_result = df.to_latex(column_format='ccc') @@ -389,8 +384,8 @@ def test_to_latex_special_escape(self): """ assert escaped_result == escaped_expected - def test_to_latex_longtable(self, frame): - frame.to_latex(longtable=True) + def test_to_latex_longtable(self, float_frame): + float_frame.to_latex(longtable=True) df = DataFrame({'a': [1, 2], 'b': ['b1', 'b2']}) withindex_result = df.to_latex(longtable=True) @@ -535,9 +530,9 @@ def test_to_latex_specified_header(self): with pytest.raises(ValueError): df.to_latex(header=['A']) - def test_to_latex_decimal(self, frame): + def test_to_latex_decimal(self, float_frame): # GH 12031 - frame.to_latex() + float_frame.to_latex() df = DataFrame({'a': [1.0, 2.1], 'b': ['b1', 'b2']}) withindex_result = df.to_latex(decimal=',')