Commit 28390b34 authored by Ole Streicher's avatar Ole Streicher

Add simple tests

parent a0c5f412
......@@ -3,16 +3,23 @@ Priority: optional
Maintainer: Debian Astro Team <debian-astro-maintainers@lists.alioth.debian.org>
Uploaders: Ole Streicher <olebole@debian.org>
Build-Depends: debhelper (>= 10),
dh-python,
iraf,
libx11-dev,
python-all-dev,
python-astropy,
python-numpy-dev,
python-setuptools (>= 0.6.4),
python-stsci.distutils (>= 0.3.2),
python-stsci.tools,
python-tk,
python3-all-dev,
python3-astropy,
python3-numpy-dev,
python3-setuptools (>= 0.6.4),
python3-stsci.distutils (>= 0.3.2)
python3-stsci.distutils (>= 0.3.2),
python3-stsci.tools,
python3-tk
Section: python
Standards-Version: 4.1.3
X-Python-Version: >= 2.6
......
#!/usr/bin/make -f
PYTHON2:=$(shell pyversions -vr)
PYTHON3:=$(shell py3versions -vr)
export PYBUILD_NAME = pyraf
%:
dh $@ --with python2,python3 --buildsystem=pybuild
override_dh_auto_test:
# autotest does not work yet.
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
test-python%:
HOME=/tmp/ PYTHONPATH=$(CURDIR)/.pybuild/pythonX.Y_$*/build python$* debian/tests/pyraf-test.py
override_dh_auto_test: $(PYTHON2:%=test-python%) $(PYTHON3:%=test-python%)
endif
override_dh_clean:
dh_clean
......
Test-Command: python debian/tests/pyraf-test.py
Depends: python-pyraf, python-tk, python-astropy
Test-Command: python3 debian/tests/pyraf-test.py
Depends: python3-pyraf, python3-tk, python3-astropy
import unittest
from io import StringIO
import os
import sys
import tempfile
wd = os.getenv('ADTTMP')
if not wd:
wd = tempfile.mkdtemp()
os.chdir(wd)
open('.hushiraf', 'a').close()
from stsci.tools import capable
capable.OF_GRAPHICS = False
from pyraf import iraf
from astropy.io import fits
class TestPyraf(unittest.TestCase):
'''Few simple tests based on
Preliminary Test Procedure for IRAF, IRAF Version V2.11, Jeannette Barnes,
Central Computer Services, National Optical Astronomy Observatories,
P.O. Box 26732, Tucson, AZ 85726, Revised September 23, 1997.
These tests are in no mean complete; they shall just test the
interaction between Pyraf and IRAF.
'''
def setUp(self):
os.chdir(wd)
def test_imcopy(self):
iraf.imcopy('dev$pix', 'image.short', verbose=False)
with fits.open('image.short.fits') as f:
self.assertEqual(len(f), 1)
self.assertEqual(f[0].header['BITPIX'], 16)
self.assertEqual(f[0].header['ORIGIN'],
'NOAO-IRAF FITS Image Kernel July 2003')
self.assertEqual(f[0].data.shape, (512, 512))
@unittest.skipIf(sys.version_info < (3,0),
'see https://github.com/spacetelescope/pyraf/issues/41')
def test_imhead(self):
out = StringIO()
iraf.imhead('dev$pix', Stdout=out)
self.assertEqual(out.getvalue(),
'dev$pix[512,512][short]: m51 B 600s\n')
def test_imarith(self):
iraf.imarith('dev$pix', '/', '1', 'image.real', pixtype='r')
with fits.open('image.real.fits') as f:
self.assertEqual(f[0].header['BITPIX'], -32)
self.assertEqual(f[0].data.shape, (512, 512))
iraf.imarith('dev$pix', '/', '1', 'image.dbl', pixtype='d')
with fits.open('image.dbl.fits') as f:
self.assertEqual(f[0].header['BITPIX'], -64)
self.assertEqual(f[0].data.shape, (512, 512))
def test_hedit(self):
iraf.imarith('dev$pix', '/', '1', 'image.real', pixtype='r')
iraf.hedit('image.real', 'title', 'm51 real', verify=False,
Stdout="/dev/null")
with fits.open('image.real.fits') as f:
self.assertEqual(f[0].header['OBJECT'], 'm51 real')
def tearDown(self):
if os.path.exists('image.real.fits'):
os.remove('image.real.fits')
if os.path.exists('image.double.fits'):
os.remove('image.double.fits')
if os.path.exists('image.short.fits'):
os.remove('image.short.fits')
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment