-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Cleanup Excel tests to make it easier to add and test additional writers #4844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@jmcnamara - this should make it much easier for you to add and test xlsxwriter. Just follow the pattern for OpenpyxlTests and XlwtTests and you should be good. |
For those interested: this doesn't add or remove tests, just makes it much easier to add new writers and new writer tests. |
and preserves skip output:
|
@jtratner That looks good. It will make adding tests for new engines very clean and straightforward. |
TST: Cleanup Excel tests to make it easier to add and test additional writers
@jtratner How do you set the writer engine from a subclass? Should it be set up via Or am I missing something more direct. |
@jmcnamara oh...very good point. wasn't thinking, give me a second, I'll put in a patch for you so you can get it to work. |
@jmcnamara you can just add it to your PR...not going to do a separate pull request. |
You can run the following to get the patch below:
Or you can copy it in yourself by saving this to a file and using diff --git a/pandas/io/tests/test_excel.py b/pandas/io/tests/test_excel.py
index 0053602..047f10c 100644
--- a/pandas/io/tests/test_excel.py
+++ b/pandas/io/tests/test_excel.py
@@ -16,6 +16,7 @@ from pandas.io.excel import (
register_writer
)
from pandas.util.testing import ensure_clean
+from pandas.core.config import set_option, get_option
import pandas.util.testing as tm
import pandas as pd
@@ -277,6 +278,12 @@ class ExcelWriterBase(SharedItems):
def setUp(self):
self.check_skip()
super(ExcelWriterBase, self).setUp()
+ self.option_name = 'io.excel.%s.writer' % self.ext
+ self.prev_engine = get_option(self.option_name)
+ set_option(self.option_name, self.engine_name)
+
+ def tearDown(self):
+ set_option(self.option_name, self.prev_engine)
def test_excel_sheet_by_name_raise(self):
_skip_if_no_xlrd()
@@ -790,6 +797,7 @@ class ExcelWriterBase(SharedItems):
class OpenpyxlTests(ExcelWriterBase, unittest.TestCase):
ext = 'xlsx'
+ engine_name = 'openpyxl'
check_skip = staticmethod(_skip_if_no_openpyxl)
def test_to_excel_styleconverter(self):
@@ -820,6 +828,7 @@ class OpenpyxlTests(ExcelWriterBase, unittest.TestCase):
class XlwtTests(ExcelWriterBase, unittest.TestCase):
ext = 'xls'
+ engine_name = 'xlwt'
check_skip = staticmethod(_skip_if_no_xlwt)
def test_to_excel_styleconverter(self): |
@jmcnamara so obviously, once you integrate, just set |
@jtratner Got it Jeff. Thanks. Your refactoring work on this and |
No description provided.