/usr/lib/python2.7/dist-packages/pyfits/tests/__init__.py is in python-pyfits 1:3.4-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | from __future__ import division # confidence high
import os
import shutil
import stat
import tempfile
import time
import warnings
import pyfits as fits
class PyfitsTestCase(object):
def setup(self):
self.data_dir = os.path.join(os.path.dirname(__file__), 'data')
self.temp_dir = tempfile.mkdtemp(prefix='pyfits-test-')
# Restore global settings to defaults
for name, value in fits.core.GLOBALS:
setattr(fits, name, value)
# Ignore deprecation warnings--this only affects Python 2.5 and 2.6,
# since deprecation warnings are ignored by defualt on 2.7
warnings.resetwarnings()
warnings.simplefilter('ignore')
warnings.simplefilter('always', UserWarning)
def teardown(self):
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
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)
|