@@ -1009,17 +1009,32 @@ def test_read_excel_squeeze(self, ext):
1009
1009
1010
1010
1011
1011
class _WriterBase (SharedItems ):
1012
- """Provides fixture to set / reset options for all writer tests"""
1013
1012
1014
1013
@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
+ """
1016
1031
option_name = 'io.excel.{ext}.writer' .format (ext = ext .strip ('.' ))
1017
1032
prev_engine = get_option (option_name )
1018
1033
set_option (option_name , engine )
1019
1034
with ensure_clean (ext ) as path :
1020
1035
self .path = path
1021
1036
yield
1022
- set_option (option_name , prev_engine )
1037
+ set_option (option_name , prev_engine ) # Roll back option change
1023
1038
1024
1039
1025
1040
@pytest .mark .parametrize ("merge_cells" , [True , False ])
0 commit comments