diff --git a/.gitignore b/.gitignore index 9608ec21..8428f5ac 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,3 @@ build dist .env .coverage* -*.Fits diff --git a/tests/test_fits.py b/tests/test_fits.py index 055c0b33..d75b063b 100644 --- a/tests/test_fits.py +++ b/tests/test_fits.py @@ -32,14 +32,12 @@ def _test_append(fits, data, names): def test_basic_write(tmp_path): import fitsio - d = tmp_path / "sub" - d.mkdir() filename_gfits = "gfits.fits" # what GLASS creates filename_tfits = "tfits.fits" # file created on the fly to test against - with user.write_catalog(d / filename_gfits, ext="CATALOG") as out, fitsio.FITS( - d / filename_tfits, "rw", clobber=True - ) as myFits: + with user.write_catalog( + tmp_path / filename_gfits, ext="CATALOG" + ) as out, fitsio.FITS(tmp_path / filename_tfits, "rw", clobber=True) as myFits: for i in range(0, my_max): array = np.arange(i, i + 1, delta) # array of size 1/delta array2 = np.arange(i + 1, i + 2, delta) # array of size 1/delta @@ -48,8 +46,8 @@ def test_basic_write(tmp_path): names = ["RA", "RB"] _test_append(myFits, arrays, names) - with fitsio.FITS(d / filename_gfits) as g_fits, fitsio.FITS( - d / filename_tfits + with fitsio.FITS(tmp_path / filename_gfits) as g_fits, fitsio.FITS( + tmp_path / filename_tfits ) as t_fits: glass_data = g_fits[1].read() test_data = t_fits[1].read() @@ -59,11 +57,8 @@ def test_basic_write(tmp_path): @pytest.mark.skipif(not HAVE_FITSIO, reason="test requires fitsio") def test_write_exception(tmp_path): - d = tmp_path / "sub" - d.mkdir() - try: - with user.write_catalog(d / filename, ext="CATALOG") as out: + with user.write_catalog(tmp_path / filename, ext="CATALOG") as out: for i in range(0, my_max): if i == except_int: raise Exception("Unhandled exception") @@ -74,7 +69,7 @@ def test_write_exception(tmp_path): except Exception: import fitsio - with fitsio.FITS(d / filename) as hdul: + with fitsio.FITS(tmp_path / filename) as hdul: data = hdul[1].read() assert data["RA"].size == except_int / delta assert data["RB"].size == except_int / delta @@ -94,6 +89,6 @@ def test_write_exception(tmp_path): def test_out_filename(tmp_path): import fitsio - fits = fitsio.FITS(filename, "rw", clobber=True) + fits = fitsio.FITS(tmp_path / filename, "rw", clobber=True) writer = user._FitsWriter(fits) - assert writer.fits._filename == filename + assert writer.fits._filename == f"{tmp_path}/{filename}"