Skip to content

TST: Use tempfiles in all tests. #5425

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
Nov 4, 2013
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ Bug Fixes
- The GroupBy methods ``transform`` and ``filter`` can be used on Series
and DataFrames that have repeated (non-unique) indices. (:issue:`4620`)
- Fix empty series not printing name in repr (:issue:`4651`)
- Make tests create temp files in temp directory by default. (:issue:`5419`)

pandas 0.12.0
-------------
Expand Down
24 changes: 16 additions & 8 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,6 @@ def _tables():
return _table_mod


def h5_open(path, mode):
tables = _tables()
return tables.openFile(path, mode)


@contextmanager
def get_store(path, **kwargs):
"""
Expand Down Expand Up @@ -389,6 +384,10 @@ def root(self):
self._check_if_open()
return self._handle.root

@property
def filename(self):
return self._path

def __getitem__(self, key):
return self.get(key)

Expand Down Expand Up @@ -475,6 +474,8 @@ def open(self, mode='a'):
mode : {'a', 'w', 'r', 'r+'}, default 'a'
See HDFStore docstring or tables.openFile for info about modes
"""
tables = _tables()

if self._mode != mode:

# if we are chaning a write mode to read, ok
Expand All @@ -501,13 +502,20 @@ def open(self, mode='a'):
fletcher32=self._fletcher32)

try:
self._handle = h5_open(self._path, self._mode)
except IOError as e: # pragma: no cover
self._handle = tables.openFile(self._path, self._mode)
except (IOError) as e: # pragma: no cover
if 'can not be written' in str(e):
print('Opening %s in read-only mode' % self._path)
self._handle = h5_open(self._path, 'r')
self._handle = tables.openFile(self._path, 'r')
else:
raise
except (Exception) as e:

# trying to read from a non-existant file causes an error which
# is not part of IOError, make it one
if self._mode == 'r' and 'Unable to open/create file' in str(e):
raise IOError(str(e))
raise

def close(self):
"""
Expand Down
Loading