Skip to content

Commit c9359e3

Browse files
committed
Added autouse to set_engine fixture
1 parent 6c8eeed commit c9359e3

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

pandas/tests/io/excel/test_writers.py

+22-23
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,6 @@ def path(ext):
3333
yield file_path
3434

3535

36-
@pytest.fixture(autouse=True)
37-
def set_engine(engine, ext):
38-
"""Fixture to set engine for use in each test case.
39-
40-
Rather than requiring `engine=...` to be provided explicitly as an
41-
argument in each test, this fixture sets a global option to dictate
42-
which engine should be used to write Excel files. After executing
43-
the test it rolls back said change to the global option.
44-
45-
Notes
46-
-----
47-
This fixture will run as part of each test method defined in the
48-
class and any subclasses, on account of the `autouse=True`
49-
argument
50-
"""
51-
option_name = "io.excel.{ext}.writer".format(ext=ext.strip("."))
52-
prev_engine = get_option(option_name)
53-
set_option(option_name, engine)
54-
yield
55-
set_option(option_name, prev_engine) # Roll back option change
56-
57-
5836
@td.skip_if_no("xlrd")
5937
@pytest.mark.parametrize("ext", [".xls", ".xlsx", ".xlsm"])
6038
class TestRoundTrip:
@@ -274,9 +252,30 @@ def test_read_excel_parse_dates(self, ext):
274252
pytest.param("xlsxwriter", ".xlsx", marks=td.skip_if_no("xlsxwriter")),
275253
],
276254
)
277-
@pytest.mark.usefixtures("set_engine")
255+
256+
# @pytest.mark.usefixtures("set_engine")
278257
class TestExcelWriter:
279258
# Base class for test cases to run with different Excel writers.
259+
@pytest.fixture(autouse=True)
260+
def set_engine(self, engine, ext):
261+
"""Fixture to set engine for use in each test case.
262+
263+
Rather than requiring `engine=...` to be provided explicitly as an
264+
argument in each test, this fixture sets a global option to dictate
265+
which engine should be used to write Excel files. After executing
266+
the test it rolls back said change to the global option.
267+
268+
Notes
269+
-----
270+
This fixture will run as part of each test method defined in the
271+
class and any subclasses, on account of the `autouse=True`
272+
argument
273+
"""
274+
option_name = "io.excel.{ext}.writer".format(ext=ext.strip("."))
275+
prev_engine = get_option(option_name)
276+
set_option(option_name, engine)
277+
yield
278+
set_option(option_name, prev_engine) # Roll back option change
280279

281280
def test_excel_sheet_size(self, path):
282281

0 commit comments

Comments
 (0)