Skip to content

Commit

Permalink
restructure yanny object for future Table support
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Alan Weaver committed Nov 11, 2015
1 parent 6d09edb commit fd2fcb8
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 288 deletions.
57 changes: 0 additions & 57 deletions pydl/pydlutils/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,3 @@
"""
This is the pydl/pydlutils/tests directory.
"""

import os
import shutil
import stat
import tempfile
import time
import warnings


class YannyTestCase(object):
"""Based on astropy.io.fits.tests.FitsTestCase.
"""
save_temp = False

def setup(self):
self.data_dir = os.path.join(os.path.dirname(__file__), 't')
self.temp_dir = tempfile.mkdtemp(prefix='yanny-test-')
# Ignore deprecation warnings--this only affects Python 2.5 and 2.6,
# since deprecation warnings are ignored by defualt on 2.7
warnings.simplefilter('ignore')
warnings.simplefilter('always', UserWarning)
# raise ValueError("I am setting up a subclass of YannyTestCase!")

def teardown(self):
warnings.resetwarnings()
if not self.save_temp:
if hasattr(self, 'temp_dir') and os.path.exists(self.temp_dir):
tries = 3
while tries:
try:
shutil.rmtree(self.temp_dir)
break
except OSError:
# Probably couldn't delete the file because for whatever
# reason a handle to it is still open/hasn't been
# garbage-collected
time.sleep(0.5)
tries -= 1
# raise ValueError("I am tearing down up a subclass of YannyTestCase!")

def copy_file(self, filename):
"""Copies a backup of a test data file to the temp dir and sets its
mode to writeable.
"""

shutil.copy(self.data(filename), self.temp(filename))
os.chmod(self.temp(filename), stat.S_IREAD | stat.S_IWRITE)

def data(self, filename):
"""Returns the path to a test data file."""

return os.path.join(self.data_dir, filename)

def temp(self, filename):
""" Returns the full path to a file in the test temp dir."""

return os.path.join(self.temp_dir, filename)
99 changes: 0 additions & 99 deletions pydl/pydlutils/tests/test_write_ndarray_to_yanny.py

This file was deleted.

Loading

0 comments on commit fd2fcb8

Please sign in to comment.