Skip to content

Commit 54e3c4a

Browse files
committed
Added autouse to set_engine fixture
1 parent 2aeb5b5 commit 54e3c4a

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

pandas/tests/io/excel/test_writers.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,6 @@ def path(ext):
3232
yield file_path
3333

3434

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

280279
def test_excel_sheet_size(self, path):
281280

0 commit comments

Comments
 (0)