Skip to content

TST: Add skip test to excelwriter contextmanager #5095

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

Merged
merged 2 commits into from
Oct 3, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions pandas/io/tests/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import pandas as pd


def _skip_if_no_xlrd(version=(0, 9)):
def _skip_if_no_xlrd():
try:
import xlrd
ver = tuple(map(int, xlrd.__VERSION__.split(".")[:2]))
if ver < version:
raise nose.SkipTest('xlrd < %s, skipping' % str(version))
if ver < (0, 9):
raise nose.SkipTest('xlrd < 0.9, skipping')
except ImportError:
raise nose.SkipTest('xlrd not installed, skipping')

Expand Down Expand Up @@ -343,17 +343,15 @@ def test_excel_sheet_by_name_raise(self):
self.assertRaises(xlrd.XLRDError, xl.parse, '0')

def test_excelwriter_contextmanager(self):
_skip_if_no_xlrd()
ext = self.ext
pth = os.path.join(self.dirpath, 'testit.{0}'.format(ext))

with ensure_clean(pth) as pth:
with ExcelWriter(pth) as writer:
self.frame.to_excel(writer, 'Data1')
self.frame2.to_excel(writer, 'Data2')
# If above test passes with outdated xlrd, next test
# does require fresh xlrd
# http://nipy.bic.berkeley.edu/builders/pandas-py2.x-wheezy-sparc/builds/148/steps/shell_4/logs/stdio
_skip_if_no_xlrd((0, 9))

with ExcelFile(pth) as reader:
found_df = reader.parse('Data1')
found_df2 = reader.parse('Data2')
Expand Down