Skip to content

Commit 849933d

Browse files
committed
Updated docstring and name of class test fixture
1 parent 164ee9c commit 849933d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

pandas/tests/io/test_excel.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -1009,17 +1009,32 @@ def test_read_excel_squeeze(self, ext):
10091009

10101010

10111011
class _WriterBase(SharedItems):
1012-
"""Provides fixture to set / reset options for all writer tests"""
10131012

10141013
@pytest.fixture(autouse=True)
1015-
def set_options(self, request, merge_cells, engine, ext):
1014+
def set_engine_and_path(self, request, merge_cells, engine, ext):
1015+
"""Fixture to set engine and open file for use in each test case
1016+
1017+
Rather than requiring `engine=...` to be provided explictly as an
1018+
argument in each test, this fixture sets a global option to dictate
1019+
which engine should be used to write Excel files. After executing
1020+
the test it rolls back said change to the global option.
1021+
1022+
It also uses a context manager to open a temporary excel file for
1023+
the function to write to, accessible via `self.path`
1024+
1025+
Notes
1026+
-----
1027+
This fixture will run as part of each test method defined in the
1028+
class and any subclasses, on account of the `autouse=True`
1029+
argument
1030+
"""
10161031
option_name = 'io.excel.{ext}.writer'.format(ext=ext.strip('.'))
10171032
prev_engine = get_option(option_name)
10181033
set_option(option_name, engine)
10191034
with ensure_clean(ext) as path:
10201035
self.path = path
10211036
yield
1022-
set_option(option_name, prev_engine)
1037+
set_option(option_name, prev_engine) # Roll back option change
10231038

10241039

10251040
@pytest.mark.parametrize("merge_cells", [True, False])

0 commit comments

Comments
 (0)