diff --git a/CHANGES.rst b/CHANGES.rst index 300a26e116..2ad7f5d4d9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -120,6 +120,14 @@ general - Remove unused asdf-transform-schemas dependency [#8337] +- Replaced all instances of pytest ``tmpdir`` and ``tmpdir_factory`` + fixtures with ``tmp_path`` and ``tmp_path_factory``. [#8327] + +- Replaced the ``_jail`` fixture from ``ci_watson`` with custom + ``tmp_cwd`` to enforce ``no:legacypath`` in the CI tests. [#8327] + +- Renamed the ``jail`` fixture with ``tmp_cwd_module``. [#8327] + jump ---- diff --git a/docs/conftest.py b/docs/conftest.py index 179de8ddeb..a124f5f63b 100644 --- a/docs/conftest.py +++ b/docs/conftest.py @@ -1,4 +1,6 @@ import pytest +import os + @pytest.fixture(autouse=True) def _docdir(request): @@ -6,8 +8,10 @@ def _docdir(request): # Trigger ONLY for doctestplus. doctest_plugin = request.config.pluginmanager.getplugin("doctestplus") if isinstance(request.node.parent, doctest_plugin._doctest_textfile_item_cls): - tmpdir = request.getfixturevalue('tmpdir') - with tmpdir.as_cwd(): - yield + tmp_path = request.getfixturevalue('tmp_path') + old_cwd = os.getcwd() + os.chdir(tmp_path) + yield + os.chdir(old_cwd) else: yield diff --git a/jwst/assign_wcs/tests/test_schemas.py b/jwst/assign_wcs/tests/test_schemas.py index e20fe3a860..7a91bfd22a 100644 --- a/jwst/assign_wcs/tests/test_schemas.py +++ b/jwst/assign_wcs/tests/test_schemas.py @@ -47,9 +47,9 @@ def distortion_model(): return dist -def test_distortion_schema(distortion_model, tmpdir): +def test_distortion_schema(distortion_model, tmp_path): """Make sure DistortionModel roundtrips""" - path = str(tmpdir.join("test_dist.asdf")) + path = tmp_path / "test_dist.asdf" dist = distortion_model dist.save(path) diff --git a/jwst/assign_wcs/tests/test_wcs.py b/jwst/assign_wcs/tests/test_wcs.py index 433fcf2106..7f057263b4 100644 --- a/jwst/assign_wcs/tests/test_wcs.py +++ b/jwst/assign_wcs/tests/test_wcs.py @@ -143,7 +143,7 @@ def test_v23_to_sky(): assert_allclose(radec, expected_ra_dec, atol=1e-10) -def test_frame_from_model_3d(tmpdir, create_model_3d): +def test_frame_from_model_3d(tmp_path, create_model_3d): """ Tests creating a frame from a data model. """ # Test CompositeFrame initialization (celestial and spectral) im = create_model_3d @@ -163,7 +163,7 @@ def test_frame_from_model_3d(tmpdir, create_model_3d): assert frame.frames[1].axes_names == ('ALPHA1A', 'BETA1A') -def test_frame_from_model_2d(tmpdir, create_model_2d): +def test_frame_from_model_2d(tmp_path, create_model_2d): """ Tests creating a frame from a data model. """ # Test 2D spatial custom frame im = create_model_2d @@ -173,13 +173,13 @@ def test_frame_from_model_2d(tmpdir, create_model_2d): assert frame.axes_names == ("RA", "DEC") -def test_create_fitswcs(tmpdir, create_model_3d): +def test_create_fitswcs(tmp_path, create_model_3d): """GWCS from create_fitswcs function and astropy.wcs give same result""" im = create_model_3d w3d = pointing.create_fitswcs(im) gra, gdec, glam = w3d(1, 1, 1) - path = str(tmpdir.join("fitswcs.fits")) + path = tmp_path / "fitswcs.fits" im.save(path) with fits.open(path) as hdulist: hdu = hdulist["SCI"] @@ -191,7 +191,7 @@ def test_create_fitswcs(tmpdir, create_model_3d): assert_allclose((ra, dec), (gra, gdec)) -def test_sip_approx(tmpdir): +def test_sip_approx(tmp_path): # some of the wcs info true_wcs = { 'ctype1': 'RA---TAN-SIP', @@ -274,7 +274,7 @@ def test_sip_approx(tmpdir): assert_allclose(fitswcs_res.dec.deg, gwcs_dec, atol=1.5e-6) # now write the file out, read it back in, and check that the fit values are preserved - path = str(tmpdir.join("tmp_sip_wcs.fits")) + path = tmp_path / "tmp_sip_wcs.fits" result.write(path) with open(path) as result_read: diff --git a/jwst/associations/lib/tests/test_diff.py b/jwst/associations/lib/tests/test_diff.py index 5dd1444005..c1063c857e 100644 --- a/jwst/associations/lib/tests/test_diff.py +++ b/jwst/associations/lib/tests/test_diff.py @@ -311,7 +311,7 @@ def test_fails(mismatched, standard=standard_asn): asn_diff.compare_asn_lists(left_asns, right_asns) -@pytest.mark.usefixtures('_jail') +@pytest.mark.usefixtures('tmp_cwd') def test_fromfiles(): """Test from files diff --git a/jwst/associations/tests/test_asn_from_list.py b/jwst/associations/tests/test_asn_from_list.py index 07e054f420..d61b33a7f6 100644 --- a/jwst/associations/tests/test_asn_from_list.py +++ b/jwst/associations/tests/test_asn_from_list.py @@ -28,6 +28,7 @@ def test_level2(): assert name.startswith('jwnoprogram-o999_none') assert isinstance(serialized, str) + def test_level2_tuple(): """Test level 2 association when passing in a tuple""" items = [('file_1.fits', 'science'), ('file_2.fits', 'background'), @@ -48,6 +49,7 @@ def test_level2_tuple(): if not items[3][1]: assert product['members'][0]['exptype'] == 'science' + def test_file_ext(): """check that the filename extension is correctly appended""" items = ['a', 'b', 'c'] @@ -63,18 +65,18 @@ def test_file_ext(): assert name.endswith('yaml') -def test_level2_from_cmdline(tmpdir): +def test_level2_from_cmdline(tmp_path): """Create a level2 association from the command line""" rule = 'DMSLevel2bBase' - path = tmpdir.join('test_asn.json') + path = tmp_path / 'test_asn.json' inlist = ['a', 'b', 'c'] args = [ - '-o', path.strpath, + '-o', str(path), '-r', rule, ] args = args + inlist Main.cli(args) - with open(path.strpath, 'r') as fp: + with open(path, 'r') as fp: asn = load_asn(fp, registry=AssociationRegistry(include_bases=True)) assert asn['asn_rule'] == 'DMSLevel2bBase' assert asn['asn_type'] == 'None' @@ -195,19 +197,19 @@ def test_cmdline_fails(): "format", ['json', 'yaml'] ) -def test_cmdline_success(format, tmpdir): +def test_cmdline_success(format, tmp_path): """Create Level3 associations in different formats""" - path = tmpdir.join('test_asn.json') + path = tmp_path / 'test_asn.json' product_name = 'test_product' inlist = ['a', 'b', 'c'] args = [ - '-o', path.strpath, + '-o', str(path), '--product-name', product_name, '--format', format ] args = args + inlist Main.cli(args) - with open(path.strpath, 'r') as fp: + with open(path, 'r') as fp: asn = load_asn(fp, format=format) assert len(asn['products']) == 1 assert asn['products'][0]['name'] == product_name @@ -219,18 +221,18 @@ def test_cmdline_success(format, tmpdir): assert inlist == expnames -def test_cmdline_change_rules(tmpdir): +def test_cmdline_change_rules(tmp_path): """Command line change the rule""" rule = 'Association' - path = tmpdir.join('test_asn.json') + path = tmp_path / 'test_asn.json' inlist = ['a', 'b', 'c'] args = [ - '-o', path.strpath, + '-o', str(path), '-r', rule, ] args = args + inlist Main.cli(args) - with open(path.strpath, 'r') as fp: + with open(path, 'r') as fp: asn = load_asn(fp, registry=AssociationRegistry(include_bases=True)) assert inlist == asn['members'] diff --git a/jwst/associations/tests/test_main.py b/jwst/associations/tests/test_main.py index 77d50f6966..e2751c34ee 100644 --- a/jwst/associations/tests/test_main.py +++ b/jwst/associations/tests/test_main.py @@ -44,7 +44,7 @@ def test_asn_candidates(pool, all_candidates, case): (['nosuchpool.csv'], 1), ] ) -def test_cmdline_status(args, expected, _jail): +def test_cmdline_status(args, expected, tmp_cwd): """Ensure command line status are as expected.""" full_args = ['asn_generate'] + args status = subprocess.run(full_args) diff --git a/jwst/associations/tests/test_pool.py b/jwst/associations/tests/test_pool.py index bb00133e6a..91f12571df 100644 --- a/jwst/associations/tests/test_pool.py +++ b/jwst/associations/tests/test_pool.py @@ -1,15 +1,16 @@ +import os from jwst.associations.tests.helpers import t_path - from jwst.associations import AssociationPool POOL_FILE = t_path('data/jw93060_20150312T160130_pool.csv') -def test_pool(tmpdir): +def test_pool(tmp_path_factory): pool = AssociationPool.read(POOL_FILE) assert len(pool) == 636 - tmp_pool = str(tmpdir.mkdir(__name__).join('tmp_pool.csv')) + tmp_path = tmp_path_factory.mktemp(__name__) + tmp_pool = tmp_path / 'tmp_pool.csv' pool.write(tmp_pool) roundtrip = AssociationPool.read(tmp_pool) diff --git a/jwst/background/tests/test_background.py b/jwst/background/tests/test_background.py index 1d67e6dee0..04eeba15b5 100644 --- a/jwst/background/tests/test_background.py +++ b/jwst/background/tests/test_background.py @@ -1,7 +1,7 @@ """ Unit tests for background subtraction """ -import os +import pathlib from astropy.stats import sigma_clipped_stats import pytest @@ -12,25 +12,21 @@ from jwst.assign_wcs import AssignWcsStep from jwst.background import BackgroundStep -from jwst.background.tests import data as data_directory from jwst.stpipe import Step from jwst.background.background_sub import robust_mean, mask_from_source_cat, no_NaN -data_path = os.path.split(os.path.abspath(data_directory.__file__))[0] - - -def get_file_path(filename): - """Construct an absolute path.""" - return os.path.join(data_path, filename) +@pytest.fixture(scope="module") +def data_path(): + return pathlib.Path(__file__).parent / "data" @pytest.fixture(scope='module') -def background(tmpdir_factory): +def background(tmp_path_factory): """Generate a background image to feed to background step""" - filename = tmpdir_factory.mktemp('background_input') - filename = str(filename.join('background.fits')) + filename = tmp_path_factory.mktemp('background_input') + filename = filename / 'background.fits' with datamodels.IFUImageModel((10, 10)) as image: image.data[:, :] = 10 image.meta.instrument.name = 'NIRSPEC' @@ -84,7 +80,7 @@ def science_image(): return image -def test_nirspec_gwa(_jail, background, science_image): +def test_nirspec_gwa(tmp_cwd, background, science_image): """Verify NIRSPEC GWA logic for in the science and background""" # open the background to read in the GWA values @@ -106,7 +102,7 @@ def test_nirspec_gwa(_jail, background, science_image): back_image.close() -def test_nirspec_gwa_xtilt(_jail, background, science_image): +def test_nirspec_gwa_xtilt(tmp_cwd, background, science_image): """Verify NIRSPEC GWA Xtilt must be the same in the science and background image""" # open the background to read in the GWA values @@ -128,7 +124,7 @@ def test_nirspec_gwa_xtilt(_jail, background, science_image): back_image.close() -def test_nirspec_gwa_ytilt(_jail, background, science_image): +def test_nirspec_gwa_ytilt(tmp_cwd, background, science_image): """Verify NIRSPEC GWA Ytilt must be the same in the science and background image""" # open the background to read in the GWA values @@ -152,7 +148,7 @@ def test_nirspec_gwa_ytilt(_jail, background, science_image): @pytest.fixture(scope='module') -def make_wfss_datamodel(): +def make_wfss_datamodel(data_path): """Generate WFSS Observation""" wcsinfo = { 'dec_ref': -27.79156387419731, @@ -201,7 +197,7 @@ def make_wfss_datamodel(): image.meta.subarray._instance.update(subarray) image.meta.exposure._instance.update(exposure) image.data = np.random.rand(2048, 2048) - image.meta.source_catalog = get_file_path('test_cat.ecsv') + image.meta.source_catalog = str(data_path / "test_cat.ecsv") return image @@ -213,7 +209,7 @@ def make_wfss_datamodel(): @pytest.mark.parametrize("pupils", ['GRISMC', 'GRISMR']) @pytest.mark.parametrize("filters", filter_list) @pytest.mark.parametrize("detectors", ['NRCALONG', 'NRCBLONG']) -def test_nrc_wfss_background(filters, pupils, detectors, make_wfss_datamodel): +def test_nrc_wfss_background(tmp_cwd, filters, pupils, detectors, make_wfss_datamodel): """Test background subtraction for NIRCAM WFSS modes.""" data = make_wfss_datamodel diff --git a/jwst/conftest.py b/jwst/conftest.py index 30a78f0390..e46d8f335e 100644 --- a/jwst/conftest.py +++ b/jwst/conftest.py @@ -3,6 +3,7 @@ import tempfile import pytest import inspect +from pathlib import Path from jwst.associations import (AssociationRegistry, AssociationPool) from jwst.associations.tests.helpers import t_path @@ -52,23 +53,33 @@ def slow(request): @pytest.fixture(scope="module") -def jail(request, tmpdir_factory): - """Run test in a pristine temporary working directory, scoped to module. - - This fixture is the same as _jail in ci_watson, but scoped to module - instead of function. This allows a fixture using it to produce files in a +def tmp_cwd_module(request, tmp_path_factory): + """ + Run test in a pristine temporary working directory, scoped to module. + This allows a fixture using it to produce files in a temporary directory, and then have the tests access them. """ old_dir = os.getcwd() path = request.module.__name__.split('.')[-1] if request._parent_request.fixturename is not None: path = path + "_" + request._parent_request.fixturename - newpath = tmpdir_factory.mktemp(path) + newpath = tmp_path_factory.mktemp(path) os.chdir(str(newpath)) yield newpath os.chdir(old_dir) +@pytest.fixture +def tmp_cwd(tmp_path): + """Perform test in a pristine temporary working directory, scoped to function.""" + old_dir = Path.cwd() + os.chdir(tmp_path) + try: + yield tmp_path + finally: + os.chdir(old_dir) + + @pytest.hookimpl(trylast=True) def pytest_configure(config): terminal_reporter = config.pluginmanager.getplugin('terminalreporter') diff --git a/jwst/cube_build/tests/test_configuration.py b/jwst/cube_build/tests/test_configuration.py index 909ea545bd..e3783c1ca8 100644 --- a/jwst/cube_build/tests/test_configuration.py +++ b/jwst/cube_build/tests/test_configuration.py @@ -202,7 +202,7 @@ def nirspec_medium_coverage(): return input_models -def test_calspec2_config(_jail, miri_ifushort_short): +def test_calspec2_config(tmp_cwd, miri_ifushort_short): """ Determine cube based on calspec2 setup """ pars_input = {} @@ -249,7 +249,7 @@ def test_calspec2_config(_jail, miri_ifushort_short): assert cube_pars['1']['par2'] == ['short', 'short'] -def test_calspec3_config_miri(_jail, miri_full_coverage): +def test_calspec3_config_miri(tmp_cwd, miri_full_coverage): """ Test CalSpec3 MIRI configuration default band cubes""" pars_input = {} @@ -322,7 +322,7 @@ def test_calspec3_config_miri(_jail, miri_full_coverage): assert cube_pars['12']['par2'] == ['long'] -def test_calspec3_config_miri_multi(_jail, miri_full_coverage): +def test_calspec3_config_miri_multi(tmp_cwd, miri_full_coverage): """ Test CalSpec3 MIRI configuration default band cubes""" pars_input = {} @@ -376,7 +376,7 @@ def test_calspec3_config_miri_multi(_jail, miri_full_coverage): 'short', 'medium', 'long'] -def test_calspec3_config_nirspec(_jail, nirspec_medium_coverage): +def test_calspec3_config_nirspec(tmp_cwd, nirspec_medium_coverage): """ Test CalSpec3 configuration for NIRSpec - default band cubes""" pars_input = {} @@ -424,7 +424,7 @@ def test_calspec3_config_nirspec(_jail, nirspec_medium_coverage): assert cube_pars['2']['par2'] == ['f170lp'] -def test_calspec3_config_nirspec_multi(_jail, nirspec_medium_coverage): +def test_calspec3_config_nirspec_multi(tmp_cwd, nirspec_medium_coverage): """ Test CalSpec3 configuration for NIRSpec - Multiband cubes""" pars_input = {} diff --git a/jwst/cube_build/tests/test_cube_build_step.py b/jwst/cube_build/tests/test_cube_build_step.py index 3d318fae4a..d93c11e43d 100644 --- a/jwst/cube_build/tests/test_cube_build_step.py +++ b/jwst/cube_build/tests/test_cube_build_step.py @@ -16,11 +16,11 @@ @pytest.fixture(scope='module') -def miri_cube_pars(tmpdir_factory): +def miri_cube_pars(tmp_path_factory): """ Set up the miri cube pars reference file """ - filename = tmpdir_factory.mktemp('cube_pars') - filename = str(filename.join('miri_cube_pars.fits')) + filename = tmp_path_factory.mktemp('cube_pars') + filename = filename / 'miri_cube_pars.fits' hdu0 = fits.PrimaryHDU() hdu0.header['REFTYPE'] = 'CUBEPAR' hdu0.header['INSTRUME'] = 'MIRI' @@ -103,7 +103,7 @@ def miri_image(): @pytest.mark.parametrize("as_filename", [True, False]) -def test_call_cube_build(_jail, miri_cube_pars, miri_image, tmp_path, as_filename): +def test_call_cube_build(tmp_cwd, miri_cube_pars, miri_image, tmp_path, as_filename): """ test defaults of step are set up and user input are defined correctly """ if as_filename: fn = tmp_path / 'miri.fits' @@ -180,7 +180,7 @@ def nirspec_data(): @pytest.mark.parametrize("as_filename", [True, False]) -def test_call_cube_build_nirspec(_jail, nirspec_data, tmp_path, as_filename): +def test_call_cube_build_nirspec(tmp_cwd, nirspec_data, tmp_path, as_filename): if as_filename: fn = tmp_path / 'test_nirspec.fits' nirspec_data.save(fn) diff --git a/jwst/cube_build/tests/test_miri_cubepars.py b/jwst/cube_build/tests/test_miri_cubepars.py index e3a65024e8..b51f8d919c 100644 --- a/jwst/cube_build/tests/test_miri_cubepars.py +++ b/jwst/cube_build/tests/test_miri_cubepars.py @@ -12,11 +12,11 @@ @pytest.fixture(scope='module') -def miri_cube_pars(tmpdir_factory): +def miri_cube_pars(tmp_path_factory): """ Set up the miri cube pars reference file """ - filename = tmpdir_factory.mktemp('cube_pars') - filename = str(filename.join('miri_cube_pars.fits')) + filename = tmp_path_factory.mktemp('cube_pars') + filename = filename / 'miri_cube_pars.fits' hdu0 = fits.PrimaryHDU() hdu0.header['REFTYPE'] = 'CUBEPAR' hdu0.header['INSTRUME'] = 'MIRI' @@ -86,7 +86,7 @@ def miri_cube_pars(tmpdir_factory): return filename -def test_miri_use_cubepars(_jail, miri_cube_pars): +def test_miri_use_cubepars(tmp_cwd, miri_cube_pars): """ Test reading in the miri cube pars file """ instrument_info = instrument_defaults.InstrumentInfo() @@ -182,7 +182,7 @@ def test_miri_use_cubepars(_jail, miri_cube_pars): assert math.isclose(this_cube.spatial_size, 0.13, abs_tol=0.00001) -def test_miri_cubepars_user_defaults(_jail, miri_cube_pars): +def test_miri_cubepars_user_defaults(tmp_cwd, miri_cube_pars): """ Read in the miri cube pars file and override some defaults """ instrument_info = instrument_defaults.InstrumentInfo() @@ -325,7 +325,7 @@ def test_miri_cubepars_user_defaults(_jail, miri_cube_pars): assert math.isclose(this_cube.rois, user_rois, abs_tol=0.00001) -def test_miri_cubepars_multiple_bands(_jail, miri_cube_pars): +def test_miri_cubepars_multiple_bands(tmp_cwd, miri_cube_pars): """Read in the miri cube pars file. Test cube has correct values when multiple bands are used """ diff --git a/jwst/cube_build/tests/test_nirspec_cubepars.py b/jwst/cube_build/tests/test_nirspec_cubepars.py index 978e3f0d92..40a38b2933 100644 --- a/jwst/cube_build/tests/test_nirspec_cubepars.py +++ b/jwst/cube_build/tests/test_nirspec_cubepars.py @@ -12,11 +12,11 @@ @pytest.fixture(scope='module') -def nirspec_cube_pars(tmpdir_factory): +def nirspec_cube_pars(tmp_path_factory): """ Set up the nirspec cube pars reference file """ - filename = tmpdir_factory.mktemp('cube_pars') - filename = str(filename.join('nirspec_cube_pars.fits')) + filename = tmp_path_factory.mktemp('cube_pars') + filename = filename / 'nirspec_cube_pars.fits' hdu0 = fits.PrimaryHDU() hdu0.header['REFTYPE'] = 'CUBEPAR' hdu0.header['INSTRUME'] = 'NIRSPEC' @@ -115,7 +115,7 @@ def nirspec_cube_pars(tmpdir_factory): return filename -def test_nirspec_cubepars(_jail, nirspec_cube_pars): +def test_nirspec_cubepars(tmp_cwd, nirspec_cube_pars): """ Read in the nirspec cube pars file """ instrument_info = instrument_defaults.InstrumentInfo() diff --git a/jwst/exp_to_source/tests/test_exp_to_source.py b/jwst/exp_to_source/tests/test_exp_to_source.py index e3abec1c6d..0216140027 100644 --- a/jwst/exp_to_source/tests/test_exp_to_source.py +++ b/jwst/exp_to_source/tests/test_exp_to_source.py @@ -1,4 +1,3 @@ -import os import pytest import numpy as np @@ -34,12 +33,11 @@ def test_model_structure(run_exp_to_source): assert outputs[str(slit.source_id)].meta.filename != in_model.meta.filename -def test_model_roundtrip(tmpdir, run_exp_to_source): +def test_model_roundtrip(tmp_path, run_exp_to_source): inputs, outputs = run_exp_to_source files = [] - path = str(tmpdir) for output in outputs: - file_path = os.path.join(path, output) + '.fits' + file_path = tmp_path / (output + '.fits') outputs[output].save(file_path) files.append(file_path) for file_path in files: diff --git a/jwst/exp_to_source/tests/test_main.py b/jwst/exp_to_source/tests/test_main.py index a71bce6f7c..9ed3321bc3 100644 --- a/jwst/exp_to_source/tests/test_main.py +++ b/jwst/exp_to_source/tests/test_main.py @@ -1,5 +1,4 @@ from glob import glob -import os from jwst.exp_to_source.tests import helpers from jwst.exp_to_source.main import Main @@ -11,20 +10,19 @@ def test_help(capsys): assert out.startswith('usage:') -def test_default_run(tmpdir, capsys): - path = str(tmpdir) +def test_default_run(tmp_path, capsys): args = [ '-o', - path + str(tmp_path) ] args.extend(helpers.INPUT_FILES) result = Main(args) assert len(result.sources) == 5 - files = glob(os.path.join(path, '*.fits')) + files = glob(str(tmp_path / '*.fits')) assert len(files) == 5 -def test_dry_run(_jail, capsys): +def test_dry_run(tmp_cwd, capsys): no_files = glob('*.fits') assert len(no_files) == 0 diff --git a/jwst/extract_1d/tests/test_apply_apcorr_ifu.py b/jwst/extract_1d/tests/test_apply_apcorr_ifu.py index 6172b3870e..0503855e7a 100644 --- a/jwst/extract_1d/tests/test_apply_apcorr_ifu.py +++ b/jwst/extract_1d/tests/test_apply_apcorr_ifu.py @@ -8,10 +8,10 @@ @pytest.fixture(scope='module') -def dummy_nirspec_ref(tmpdir_factory): +def dummy_nirspec_ref(tmp_path_factory): """ Generate a dummy apcorr ref file """ - filename = tmpdir_factory.mktemp('dummy_apcorr') - filename = str(filename.join('dummy_nirspec_apcorr.asdf')) + filename = tmp_path_factory.mktemp('dummy_apcorr') + filename = filename / 'dummy_nirspec_apcorr.asdf' refap = {} refap['meta'] = {} @@ -51,10 +51,10 @@ def dummy_nirspec_ref(tmpdir_factory): @pytest.fixture(scope='module') -def dummy_miri_ref(tmpdir_factory): +def dummy_miri_ref(tmp_path_factory): """ Generate a dummy apcorr ref file """ - filename = tmpdir_factory.mktemp('dummy_apcorr') - filename = str(filename.join('dummy_miri_apcorr.asdf')) + filename = tmp_path_factory.mktemp('dummy_apcorr') + filename = filename / 'dummy_miri_apcorr.asdf' refap = {} refap['meta'] = {} @@ -129,7 +129,7 @@ def test_select_apcorr_nirspec(nirspec_cube): assert apcorr_cls == ApCorrRadial -def test_table_type_miri(_jail, dummy_miri_ref, miri_cube): +def test_table_type_miri(tmp_cwd, dummy_miri_ref, miri_cube): dummy_wave = np.zeros(100) + 0.5 with MirMrsApcorrModel(dummy_miri_ref) as apcorr_model: table = apcorr_model.apcorr_table @@ -139,7 +139,7 @@ def test_table_type_miri(_jail, dummy_miri_ref, miri_cube): assert np.all(table.wavelength == dummy_wave) -def test_table_type_nirspec(_jail, dummy_nirspec_ref, nirspec_cube): +def test_table_type_nirspec(tmp_cwd, dummy_nirspec_ref, nirspec_cube): dummy_wave = np.zeros(100) + 0.5 with NrsIfuApcorrModel(dummy_nirspec_ref) as apcorr_model: table = apcorr_model.apcorr_table diff --git a/jwst/jump/tests/test_jump_step.py b/jwst/jump/tests/test_jump_step.py index acdf0fad42..3ff600e900 100644 --- a/jwst/jump/tests/test_jump_step.py +++ b/jwst/jump/tests/test_jump_step.py @@ -11,12 +11,12 @@ @pytest.fixture(scope="module") -def generate_miri_reffiles(tmpdir_factory): +def generate_miri_reffiles(tmp_path_factory): def _generate_miri_reffiles(xsize=103, ysize=102, ingain=6): - gainfile = str(tmpdir_factory.mktemp("data").join("gain.fits")) - readnoisefile = str(tmpdir_factory.mktemp("data").join('readnoise.fits')) + gainfile = tmp_path_factory.mktemp("data") / "gain.fits" + readnoisefile = tmp_path_factory.mktemp("data") / 'readnoise.fits' ingain = ingain xsize = xsize @@ -43,17 +43,17 @@ def _generate_miri_reffiles(xsize=103, ysize=102, ingain=6): readnoise_model.save(readnoisefile) readnoise_model.close() - return gainfile, readnoisefile + return str(gainfile), str(readnoisefile) return _generate_miri_reffiles @pytest.fixture(scope="module") -def generate_nircam_reffiles(tmpdir_factory): +def generate_nircam_reffiles(tmp_path_factory): def _generate_nircam_reffiles(xsize=20, ysize=20, ingain=6): - gainfile = str(tmpdir_factory.mktemp("ndata").join("gain.fits")) - readnoisefile = str(tmpdir_factory.mktemp("ndata").join('readnoise.fits')) + gainfile = tmp_path_factory.mktemp("ndata") / "gain.fits" + readnoisefile = tmp_path_factory.mktemp("ndata") / 'readnoise.fits' ingain = ingain xsize = xsize @@ -80,7 +80,7 @@ def _generate_nircam_reffiles(xsize=20, ysize=20, ingain=6): readnoise_model.save(readnoisefile) readnoise_model.close() - return gainfile, readnoisefile + return str(gainfile), str(readnoisefile) return _generate_nircam_reffiles diff --git a/jwst/lib/tests/test_pointing_summary.py b/jwst/lib/tests/test_pointing_summary.py index 072557e9f2..b7665e1292 100644 --- a/jwst/lib/tests/test_pointing_summary.py +++ b/jwst/lib/tests/test_pointing_summary.py @@ -29,7 +29,7 @@ def engdb(): @pytest.fixture(scope='module') -def data_path(jail): +def data_path(tmp_cwd_module): """Create data file with needed header parameters""" model = ImageModel() diff --git a/jwst/lib/tests/test_velocity_aberration.py b/jwst/lib/tests/test_velocity_aberration.py index 8cbed1d3f2..99f4726781 100644 --- a/jwst/lib/tests/test_velocity_aberration.py +++ b/jwst/lib/tests/test_velocity_aberration.py @@ -2,6 +2,7 @@ Test script for set_velocity_aberration.py """ import subprocess + from numpy import isclose from astropy.io import fits import jwst.datamodels as dm @@ -29,9 +30,10 @@ def test_compute_va_effects_zero_velocity(): assert isclose(va_dec, GOOD_POS[1], atol=1e-16) -def test_velocity_aberration_script(tmpdir): +def test_velocity_aberration_script(tmp_path): """Test the whole script on a FITS file""" - path = str(tmpdir.join("velocity_aberration_tmpfile.fits")) + + path = tmp_path / "velocity_aberration_tmpfile.fits" model = dm.ImageModel() model.meta.ephemeris.velocity_x_bary = GOOD_VELOCITY[0] model.meta.ephemeris.velocity_y_bary = GOOD_VELOCITY[1] diff --git a/jwst/master_background/tests/test_master_background.py b/jwst/master_background/tests/test_master_background.py index 43853f1f58..bf3fb2e136 100644 --- a/jwst/master_background/tests/test_master_background.py +++ b/jwst/master_background/tests/test_master_background.py @@ -17,16 +17,17 @@ @pytest.fixture(scope='module') -def user_background(tmpdir_factory): +def user_background(tmp_path_factory): """Generate a user background spectrum""" - filename = tmpdir_factory.mktemp('master_background_user_input') - filename = str(filename.join('user_background.fits')) + filename = tmp_path_factory.mktemp('master_background_user_input') + filename = filename / 'user_background.fits' wavelength = np.linspace(0.5, 25, num=100) flux = np.linspace(2.0, 2.2, num=100) data = create_background(wavelength, flux) data.save(filename) - return filename + # filename must be string not Path to validate with current stpipe version + return str(filename) @pytest.fixture(scope='function') @@ -52,7 +53,7 @@ def science_image(): return image -def test_master_background_userbg(_jail, user_background, science_image): +def test_master_background_userbg(tmp_cwd, user_background, science_image): """Verify data can run through the step with a user-supplied background""" # Run with a user-supplied background and verify this is recorded in header @@ -67,7 +68,7 @@ def test_master_background_userbg(_jail, user_background, science_image): assert result.meta.background.master_background_file == 'user_background.fits' -def test_master_background_logic(_jail, user_background, science_image): +def test_master_background_logic(tmp_cwd, user_background, science_image): """Verify if calspec 2 background step was run the master background step will be skipped""" # the background step in calspec2 was done diff --git a/jwst/mrs_imatch/tests/test_apply_background.py b/jwst/mrs_imatch/tests/test_apply_background.py index fc50f7f78c..ff26907bd7 100644 --- a/jwst/mrs_imatch/tests/test_apply_background.py +++ b/jwst/mrs_imatch/tests/test_apply_background.py @@ -88,7 +88,7 @@ def miri_dither_ch12(): return input_models -def test_apply_background_2d(_jail, miri_dither_ch12): +def test_apply_background_2d(tmp_cwd, miri_dither_ch12): """ Test if background polynomial is set it is subtracted correctly""" all_models = ModelContainer(miri_dither_ch12) diff --git a/jwst/mrs_imatch/tests/test_configuration.py b/jwst/mrs_imatch/tests/test_configuration.py index 53330f6cc4..39dbe5cabe 100644 --- a/jwst/mrs_imatch/tests/test_configuration.py +++ b/jwst/mrs_imatch/tests/test_configuration.py @@ -57,7 +57,7 @@ def miri_dither_ch12(): return input_models -def test_imatch_background_subtracted(_jail, miri_dither_ch12): +def test_imatch_background_subtracted(tmp_cwd, miri_dither_ch12): """ Test if data is already background subtracted - raise error""" all_models = ModelContainer(miri_dither_ch12) @@ -73,7 +73,7 @@ def test_imatch_background_subtracted(_jail, miri_dither_ch12): step.run(new_container) -def test_imatch_background_reset(_jail, miri_dither_ch12): +def test_imatch_background_reset(tmp_cwd, miri_dither_ch12): """ Test if background polynomial is already determined - reset it""" all_models = ModelContainer(miri_dither_ch12) @@ -107,7 +107,7 @@ def test_imatch_background_reset(_jail, miri_dither_ch12): assert test == 0 -def test_find_channel_index(_jail, miri_dither_ch12): +def test_find_channel_index(tmp_cwd, miri_dither_ch12): """ Test if correct channel index is returned """ # channel 1 - model only has 1 background polynomial diff --git a/jwst/outlier_detection/tests/test_outlier_detection.py b/jwst/outlier_detection/tests/test_outlier_detection.py index 076655f20d..354ce57895 100644 --- a/jwst/outlier_detection/tests/test_outlier_detection.py +++ b/jwst/outlier_detection/tests/test_outlier_detection.py @@ -160,7 +160,7 @@ def we_three_sci(): return we_many_sci(numsci=3) -def test_outlier_step_no_outliers(we_three_sci, _jail): +def test_outlier_step_no_outliers(we_three_sci, tmp_cwd): """Test whole step, no outliers""" container = ModelContainer(list(we_three_sci)) pristine = container.copy() @@ -177,7 +177,7 @@ def test_outlier_step_no_outliers(we_three_sci, _jail): np.testing.assert_allclose(image.dq, corrected.dq) -def test_outlier_step(we_three_sci, _jail): +def test_outlier_step(we_three_sci, tmp_cwd): """Test whole step with an outlier including saving intermediate and results files""" container = ModelContainer(list(we_three_sci)) @@ -200,7 +200,7 @@ def test_outlier_step(we_three_sci, _jail): assert result[0].dq[12, 12] == OUTLIER_DO_NOT_USE -def test_outlier_step_on_disk(we_three_sci, _jail): +def test_outlier_step_on_disk(we_three_sci, tmp_cwd): """Test whole step with an outlier including saving intermediate and results files""" for model in we_three_sci: @@ -230,7 +230,7 @@ def test_outlier_step_on_disk(we_three_sci, _jail): assert result[0].dq[12, 12] == OUTLIER_DO_NOT_USE -def test_outlier_step_square_source_no_outliers(we_three_sci, _jail): +def test_outlier_step_square_source_no_outliers(we_three_sci, tmp_cwd): """Test whole step with square source with sharp edges, no outliers""" container = ModelContainer(list(we_three_sci)) @@ -256,7 +256,7 @@ def test_outlier_step_square_source_no_outliers(we_three_sci, _jail): @pytest.mark.parametrize("exptype", IMAGE_MODES) -def test_outlier_step_image_weak_CR_dither(exptype, _jail): +def test_outlier_step_image_weak_CR_dither(exptype, tmp_cwd): """Test whole step with an outlier for imaging modes""" bkg = 1.5 sig = 0.02 @@ -283,7 +283,7 @@ def test_outlier_step_image_weak_CR_dither(exptype, _jail): @pytest.mark.parametrize("exptype, tsovisit", exptypes_tso + exptypes_coron) -def test_outlier_step_image_weak_CR_nodither(exptype, tsovisit, _jail): +def test_outlier_step_image_weak_CR_nodither(exptype, tsovisit, tmp_cwd): """Test whole step with an outlier for TSO & coronagraphic modes""" bkg = 1.5 sig = 0.02 diff --git a/jwst/ramp_fitting/tests/test_ramp_fit_step.py b/jwst/ramp_fitting/tests/test_ramp_fit_step.py index dc2ebc1662..381996e978 100644 --- a/jwst/ramp_fitting/tests/test_ramp_fit_step.py +++ b/jwst/ramp_fitting/tests/test_ramp_fit_step.py @@ -179,10 +179,10 @@ def test_ramp_fit_step(generate_miri_reffiles, setup_inputs, max_cores): assert slopes.meta.cal_step.ramp_fit == "COMPLETE" -def test_subarray_5groups(tmpdir_factory): +def test_subarray_5groups(tmp_path_factory): # all pixel values are zero. So slope should be zero - gainfile = str(tmpdir_factory.mktemp("data").join("gain.fits")) - readnoisefile = str(tmpdir_factory.mktemp("data").join('readnoise.fits')) + gainfile = tmp_path_factory.mktemp("data") / "gain.fits" + readnoisefile = tmp_path_factory.mktemp("data") / 'readnoise.fits' model1, gdq, rnModel, pixdq, err, gain = setup_subarray_inputs( ngroups=5, subxstart=10, subystart=20, subxsize=5, subysize=15, readnoise=50) @@ -198,7 +198,7 @@ def test_subarray_5groups(tmpdir_factory): # Call ramp fit through the step class slopes, cube_model = RampFitStep.call( - model1, override_gain=gainfile, override_readnoise=readnoisefile, + model1, override_gain=str(gainfile), override_readnoise=str(readnoisefile), maximum_cores="none", save_opt=True) assert slopes is not None diff --git a/jwst/regtest/conftest.py b/jwst/regtest/conftest.py index 34898f3e56..856309bed1 100644 --- a/jwst/regtest/conftest.py +++ b/jwst/regtest/conftest.py @@ -104,11 +104,11 @@ def artifactory_result_path(): postmortem(request, 'sdpdata_module') if rtdata: try: - # The _jail fixture from ci_watson sets tmp_path + # The tmp_cwd fixture sets tmp_path cwd = str(request.node.funcargs['tmp_path']) except KeyError: - # The jail fixture (module-scoped) returns the path - cwd = str(request.node.funcargs['jail']) + # The tmp_cwd_module fixture (module-scoped) returns the path + cwd = str(request.node.funcargs['tmp_cwd_module']) rtdata.remote_results_path = artifactory_result_path() rtdata.test_name = request.node.name # Dump the failed test traceback into rtdata @@ -210,12 +210,12 @@ def _rtdata_fixture_implementation(artifactory_repos, envopt, request): @pytest.fixture(scope='function') -def rtdata(artifactory_repos, envopt, request, _jail): +def rtdata(artifactory_repos, envopt, request, tmp_cwd): return _rtdata_fixture_implementation(artifactory_repos, envopt, request) @pytest.fixture(scope='module') -def rtdata_module(artifactory_repos, envopt, request, jail): +def rtdata_module(artifactory_repos, envopt, request, tmp_cwd_module): return _rtdata_fixture_implementation(artifactory_repos, envopt, request) @@ -227,7 +227,7 @@ def _sdpdata_fixture_implementation(artifactory_repos, envopt, request): @pytest.fixture(scope='module') -def sdpdata_module(artifactory_repos, envopt, request, jail): +def sdpdata_module(artifactory_repos, envopt, request, tmp_cwd_module): return _sdpdata_fixture_implementation(artifactory_repos, envopt, request) diff --git a/jwst/regtest/regtestdata.py b/jwst/regtest/regtestdata.py index 34f53dbda2..7eaa91243f 100644 --- a/jwst/regtest/regtestdata.py +++ b/jwst/regtest/regtestdata.py @@ -419,7 +419,8 @@ def text_diff(from_path, to_path): with open(to_path) as fh: to_lines = fh.readlines() - diffs = unified_diff(from_lines, to_lines, from_path, to_path) + # convert path objects to strings because difflib requires strings + diffs = unified_diff(from_lines, to_lines, str(from_path), str(to_path)) diff = list(diffs) if len(diff) > 0: diff --git a/jwst/regtest/test_fgs_guider.py b/jwst/regtest/test_fgs_guider.py index a722d15b9e..af1e2b2a90 100644 --- a/jwst/regtest/test_fgs_guider.py +++ b/jwst/regtest/test_fgs_guider.py @@ -11,7 +11,7 @@ @pytest.fixture(scope='module', params=file_roots, ids=file_roots) -def run_guider_pipelines(jail, rtdata_module, request): +def run_guider_pipelines(rtdata_module, request): """Run pipeline for guider data""" rtdata = rtdata_module rtdata.get_data('fgs/level1b/' + request.param + '_uncal.fits') diff --git a/jwst/regtest/test_infrastructure.py b/jwst/regtest/test_infrastructure.py index 154220f0cc..7cbe03c4aa 100644 --- a/jwst/regtest/test_infrastructure.py +++ b/jwst/regtest/test_infrastructure.py @@ -9,19 +9,19 @@ @pytest.mark.bigdata -def test_regtestdata_get_data(rtdata): +def test_regtestdata_get_data(rtdata, tmp_cwd): rtdata.get_data("infrastructure/test_regtestdata/file1_rate.fits") rtdata.output = "file1_cal.fits" - assert rtdata.input == os.path.join(os.getcwd(), "file1_rate.fits") + assert rtdata.input == str(tmp_cwd / "file1_rate.fits") @pytest.mark.bigdata -def test_regtestdata_get_truth(rtdata): +def test_regtestdata_get_truth(rtdata, tmp_cwd): rtdata.get_truth("infrastructure/test_regtestdata/file1_rate.fits") rtdata.output = "file1_rate.fits" - assert rtdata.truth == os.path.join(os.getcwd(), "truth", "file1_rate.fits") + assert rtdata.truth == str(tmp_cwd / "truth" / "file1_rate.fits") @pytest.mark.bigdata @@ -39,10 +39,10 @@ def test_fitsdiff_defaults(fitsdiff_default_kwargs): @pytest.fixture -def two_tables(tmpdir): +def two_tables(tmp_path): """Return identical astropy tables written to 2 .ecsv file paths""" - path1 = str(tmpdir.join("catalog1.ecsv")) - path2 = str(tmpdir.join("catalog2.ecsv")) + path1 = tmp_path / "catalog1.ecsv" + path2 = tmp_path / "catalog2.ecsv" a = np.array([1, 4, 5], dtype=float) b = [2.0, 5.0, 8.5] c = ['x', 'y', 'z'] @@ -133,9 +133,9 @@ def test_diff_astropy_tables_all_equal(diff_astropy_tables, two_tables): assert diff_astropy_tables(path1, path2) -def test_text_diff(tmpdir): - path1 = str(tmpdir.join("test1.txt")) - path2 = str(tmpdir.join("test2.txt")) +def test_text_diff(tmp_path): + path1 = tmp_path / "test1.txt" + path2 = tmp_path / "test2.txt" with open(path1, "w") as text_file: print("foo", file=text_file) with open(path2, "w") as text_file: diff --git a/jwst/regtest/test_miri_coron3.py b/jwst/regtest/test_miri_coron3.py index a6c9280b71..d10af9e65d 100644 --- a/jwst/regtest/test_miri_coron3.py +++ b/jwst/regtest/test_miri_coron3.py @@ -5,7 +5,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): """Run calwebb_coron3 on MIRI 4QPM coronographic data.""" rtdata = rtdata_module rtdata.get_asn("miri/coron/jw01386-c1002_20230109t015044_coron3_00001_asn.json") diff --git a/jwst/regtest/test_miri_coron_image2.py b/jwst/regtest/test_miri_coron_image2.py index e5143c1bc0..c43dea38d9 100644 --- a/jwst/regtest/test_miri_coron_image2.py +++ b/jwst/regtest/test_miri_coron_image2.py @@ -7,7 +7,7 @@ from jwst.stpipe import Step @pytest.fixture(scope='module') -def run_image2(jail, rtdata_module): +def run_image2(rtdata_module): """Run the calwebb_image2 pipeline""" rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_dark.py b/jwst/regtest/test_miri_dark.py index 04ac6ca15c..61aeb1f9d0 100644 --- a/jwst/regtest/test_miri_dark.py +++ b/jwst/regtest/test_miri_dark.py @@ -9,7 +9,7 @@ 'exposure', ['jw00001001001_01101_00001_mirimage', 'jw02201001001_01101_00001_MIRIMAGE'] ) -def test_miri_dark_pipeline(exposure, _jail, rtdata, fitsdiff_default_kwargs): +def test_miri_dark_pipeline(exposure, rtdata, fitsdiff_default_kwargs): """Test the DarkPipeline on MIRI dark exposures""" rtdata.get_data(f"miri/image/{exposure}_uncal.fits") @@ -28,7 +28,7 @@ def test_miri_dark_pipeline(exposure, _jail, rtdata, fitsdiff_default_kwargs): 'exposure', ['jw01033005001_04103_00001-seg003_mirimage'] ) -def test_miri_segmented_dark(exposure, _jail, rtdata, fitsdiff_default_kwargs): +def test_miri_segmented_dark(exposure, rtdata, fitsdiff_default_kwargs): """Test the dark_current step on MIRI segmented exposures""" rtdata.get_data(f"miri/image/{exposure}_linearity.fits") diff --git a/jwst/regtest/test_miri_lrs_dedicated_mbkg.py b/jwst/regtest/test_miri_lrs_dedicated_mbkg.py index 47e48d5fe0..50ef78cb5c 100644 --- a/jwst/regtest/test_miri_lrs_dedicated_mbkg.py +++ b/jwst/regtest/test_miri_lrs_dedicated_mbkg.py @@ -6,7 +6,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_lrs_masterbg_user.py b/jwst/regtest/test_miri_lrs_masterbg_user.py index b9991768de..e57570bdbc 100644 --- a/jwst/regtest/test_miri_lrs_masterbg_user.py +++ b/jwst/regtest/test_miri_lrs_masterbg_user.py @@ -6,7 +6,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_lrs_nod_masterbg.py b/jwst/regtest/test_miri_lrs_nod_masterbg.py index 592099a23e..0a3b2ba203 100644 --- a/jwst/regtest/test_miri_lrs_nod_masterbg.py +++ b/jwst/regtest/test_miri_lrs_nod_masterbg.py @@ -6,7 +6,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_lrs_slit_spec2.py b/jwst/regtest/test_miri_lrs_slit_spec2.py index aaf631fb4f..7340a0b0c5 100644 --- a/jwst/regtest/test_miri_lrs_slit_spec2.py +++ b/jwst/regtest/test_miri_lrs_slit_spec2.py @@ -10,7 +10,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): """Run the calwebb_spec2 pipeline on an ASN of nodded MIRI LRS fixedslit exposures.""" rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_lrs_slit_spec3.py b/jwst/regtest/test_miri_lrs_slit_spec3.py index 68410757db..9ea82fb64a 100644 --- a/jwst/regtest/test_miri_lrs_slit_spec3.py +++ b/jwst/regtest/test_miri_lrs_slit_spec3.py @@ -13,7 +13,7 @@ scope="module", params=["default_wcs", "user_wcs", "user_wcs+shape", "user_wcs+shape1"] ) -def run_pipeline(jail, rtdata_module, request): +def run_pipeline(rtdata_module, request): """ Run the calwebb_spec3 pipeline on an ASN of nodded MIRI LRS fixed-slit exposures using different options for the WCS and output diff --git a/jwst/regtest/test_miri_lrs_slitless.py b/jwst/regtest/test_miri_lrs_slitless.py index d39b08f296..de4733050f 100644 --- a/jwst/regtest/test_miri_lrs_slitless.py +++ b/jwst/regtest/test_miri_lrs_slitless.py @@ -15,7 +15,7 @@ @pytest.fixture(scope="module") -def run_tso1_pipeline(jail, rtdata_module): +def run_tso1_pipeline(rtdata_module): """Run the calwebb_tso1 pipeline on a MIRI LRS slitless exposure.""" rtdata = rtdata_module rtdata.get_data(f"miri/lrs/{DATASET1_ID}_uncal.fits") @@ -34,7 +34,7 @@ def run_tso1_pipeline(jail, rtdata_module): @pytest.fixture(scope="module") -def run_tso_spec2_pipeline(run_tso1_pipeline, jail, rtdata_module): +def run_tso_spec2_pipeline(run_tso1_pipeline, rtdata_module): """Run the calwebb_tso-spec2 pipeline on a MIRI LRS slitless exposure.""" rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_mrs_dedicated_mbkg.py b/jwst/regtest/test_miri_mrs_dedicated_mbkg.py index d01d52a8fb..93e5bcdba3 100644 --- a/jwst/regtest/test_miri_mrs_dedicated_mbkg.py +++ b/jwst/regtest/test_miri_mrs_dedicated_mbkg.py @@ -6,7 +6,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_mrs_nod_masterbg.py b/jwst/regtest/test_miri_mrs_nod_masterbg.py index 7a3449c544..d12a3bae20 100644 --- a/jwst/regtest/test_miri_mrs_nod_masterbg.py +++ b/jwst/regtest/test_miri_mrs_nod_masterbg.py @@ -6,7 +6,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_mrs_spec2.py b/jwst/regtest/test_miri_mrs_spec2.py index 5149f4e068..3e4a23cb9f 100644 --- a/jwst/regtest/test_miri_mrs_spec2.py +++ b/jwst/regtest/test_miri_mrs_spec2.py @@ -16,7 +16,7 @@ @pytest.fixture(scope='module') -def run_spec2(jail, rtdata_module): +def run_spec2(rtdata_module): """Run the Spec2Pipeline on a single exposure""" rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_mrs_spec3.py b/jwst/regtest/test_miri_mrs_spec3.py index 017eb942ff..1b71a4c984 100644 --- a/jwst/regtest/test_miri_mrs_spec3.py +++ b/jwst/regtest/test_miri_mrs_spec3.py @@ -9,7 +9,7 @@ @pytest.fixture(scope='module') -def run_spec3_ifushort(jail, rtdata_module): +def run_spec3_ifushort(rtdata_module): """Run the Spec3Pipeline on association with 2 bands on IFUSHORT""" # Test has bands medium and long for IFUSHORT @@ -30,7 +30,7 @@ def run_spec3_ifushort(jail, rtdata_module): @pytest.fixture(scope='module') -def run_spec3_ifulong(jail, rtdata_module): +def run_spec3_ifulong(rtdata_module): """Run the Spec3Pipeline dithered flight data """ # Test has bands medium and long for IFULONG @@ -50,7 +50,7 @@ def run_spec3_ifulong(jail, rtdata_module): @pytest.fixture(scope='module') -def run_spec3_ifushort_emsm(jail, rtdata_module): +def run_spec3_ifushort_emsm(rtdata_module): """Run the Spec3Pipeline (cube_build using weighting emsm) on association with 2 bands on IFUSHORT""" # Test has bands medium and long for IFUSHORT @@ -72,7 +72,7 @@ def run_spec3_ifushort_emsm(jail, rtdata_module): @pytest.fixture(scope='module') -def run_spec3_ifushort_extract1d(jail, rtdata_module): +def run_spec3_ifushort_extract1d(rtdata_module): """Run the Spec3Pipeline on association with 2 bands on IFUSHORT""" # Test has bands medium and long for IFUSHORT diff --git a/jwst/regtest/test_miri_mrs_spec3_moving_target.py b/jwst/regtest/test_miri_mrs_spec3_moving_target.py index 9794f788c2..1cd7c97de9 100644 --- a/jwst/regtest/test_miri_mrs_spec3_moving_target.py +++ b/jwst/regtest/test_miri_mrs_spec3_moving_target.py @@ -10,7 +10,7 @@ @pytest.fixture(scope='module') -def run_spec3_moving_target(jail, rtdata_module): +def run_spec3_moving_target(rtdata_module): """Run the Spec3Pipeline dithered flight data """ # Association has 2 exposures from IFUSHORT diff --git a/jwst/regtest/test_miri_mrs_tso.py b/jwst/regtest/test_miri_mrs_tso.py index a4efa7f1c4..434a3cbaf9 100644 --- a/jwst/regtest/test_miri_mrs_tso.py +++ b/jwst/regtest/test_miri_mrs_tso.py @@ -10,7 +10,7 @@ @pytest.fixture(scope='module') -def run_spec2(jail, rtdata_module): +def run_spec2(rtdata_module): """Run the Spec2Pipeline on a single exposure""" rtdata = rtdata_module diff --git a/jwst/regtest/test_miri_setpointing.py b/jwst/regtest/test_miri_setpointing.py index 40ee8d8d82..9582cb01d7 100644 --- a/jwst/regtest/test_miri_setpointing.py +++ b/jwst/regtest/test_miri_setpointing.py @@ -12,7 +12,7 @@ @pytest.mark.bigdata -def test_miri_setpointing(_jail, rtdata, engdb, fitsdiff_default_kwargs): +def test_miri_setpointing(rtdata, engdb, fitsdiff_default_kwargs): """ Regression test of the set_telescope_pointing script on a level-1b MIRI image. """ diff --git a/jwst/regtest/test_miri_spectral_leak.py b/jwst/regtest/test_miri_spectral_leak.py index 4896b97938..4fc2aceffb 100644 --- a/jwst/regtest/test_miri_spectral_leak.py +++ b/jwst/regtest/test_miri_spectral_leak.py @@ -8,7 +8,7 @@ 'output', ['test_spectral_leak_asn_0_spectralleakstep.fits', 'test_spectral_leak_asn_1_spectralleakstep.fits'] ) -def test_miri_spectral_leak(output, _jail, rtdata, fitsdiff_default_kwargs): +def test_miri_spectral_leak(output, rtdata, fitsdiff_default_kwargs): """Run cube_build on single file using coord system = ifu_align""" rtdata.get_asn("miri/mrs/test_spectral_leak_asn.json") diff --git a/jwst/regtest/test_nircam_align_to_gaia.py b/jwst/regtest/test_nircam_align_to_gaia.py index 6eac063cb1..c91e647207 100644 --- a/jwst/regtest/test_nircam_align_to_gaia.py +++ b/jwst/regtest/test_nircam_align_to_gaia.py @@ -7,7 +7,7 @@ @pytest.fixture(scope="module") -def run_image3pipeline(rtdata_module, jail): +def run_image3pipeline(rtdata_module): ''' Run calwebb_image3 on NIRCam imaging and align to gaia ''' rtdata = rtdata_module diff --git a/jwst/regtest/test_nircam_coron3.py b/jwst/regtest/test_nircam_coron3.py index 73dc117456..f66c8cac11 100644 --- a/jwst/regtest/test_nircam_coron3.py +++ b/jwst/regtest/test_nircam_coron3.py @@ -5,7 +5,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): """Run calwebb_coron3 on coronographic data.""" rtdata = rtdata_module rtdata.get_asn("nircam/coron/jw01386-c1020_20220909t073458_coron3_002a_asn.json") diff --git a/jwst/regtest/test_nircam_image.py b/jwst/regtest/test_nircam_image.py index ed65f3d351..eed2226a78 100644 --- a/jwst/regtest/test_nircam_image.py +++ b/jwst/regtest/test_nircam_image.py @@ -11,7 +11,7 @@ @pytest.fixture(scope="module") -def run_detector1pipeline(jail, rtdata_module): +def run_detector1pipeline(rtdata_module): """Run calwebb_detector1 on NIRCam imaging long data""" rtdata = rtdata_module rtdata.get_data("nircam/image/jw01538046001_03105_00001_nrcalong_uncal.fits") @@ -31,7 +31,7 @@ def run_detector1pipeline(jail, rtdata_module): @pytest.fixture(scope="module") -def run_image2pipeline(run_detector1pipeline, jail, rtdata_module): +def run_image2pipeline(run_detector1pipeline, rtdata_module): """Run calwebb_image2 on NIRCam imaging long data""" rtdata = rtdata_module rtdata.input = "jw01538046001_03105_00001_nrcalong_rate.fits" @@ -43,7 +43,7 @@ def run_image2pipeline(run_detector1pipeline, jail, rtdata_module): @pytest.fixture(scope="module") -def run_image3pipeline(run_image2pipeline, rtdata_module, jail): +def run_image3pipeline(run_image2pipeline, rtdata_module): """Run calwebb_image3 on NIRCam imaging long data""" rtdata = rtdata_module # Grab rest of _rate files for the asn and run image2 pipeline on each to @@ -170,8 +170,9 @@ def test_nircam_image_stage3_segm(run_image3pipeline, rtdata_module, fitsdiff_de @pytest.fixture() -def run_image3_closedfile(rtdata, jail): +def run_image3_closedfile(rtdata_module): """Run calwebb_image3 on NIRCam imaging with data that had a closed file issue.""" + rtdata = rtdata_module rtdata.get_asn("nircam/image/fail_short_image3_asn.json") args = ["calwebb_image3", rtdata.input] diff --git a/jwst/regtest/test_nircam_subarray_4amp.py b/jwst/regtest/test_nircam_subarray_4amp.py index 8a0b5ed099..c0d7a77bb5 100644 --- a/jwst/regtest/test_nircam_subarray_4amp.py +++ b/jwst/regtest/test_nircam_subarray_4amp.py @@ -14,7 +14,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): """Run calwebb_detector1 pipeline on NIRCAM subarray data.""" rtdata = rtdata_module rtdata.get_data("nircam/subarray/jw00617196001_02102_00001_nrca4_uncal.fits") diff --git a/jwst/regtest/test_nircam_tsgrism.py b/jwst/regtest/test_nircam_tsgrism.py index 42e9cb07cb..efd09185c6 100644 --- a/jwst/regtest/test_nircam_tsgrism.py +++ b/jwst/regtest/test_nircam_tsgrism.py @@ -7,7 +7,7 @@ @pytest.fixture(scope="module") -def run_pipelines(jail, rtdata_module): +def run_pipelines(rtdata_module): """Run stage 2-3 tso pipelines on NIRCAM TSO grism data.""" rtdata = rtdata_module @@ -71,7 +71,7 @@ def test_nircam_tsgrism_stage3_whtlt(run_pipelines): @pytest.mark.bigdata -def test_nircam_setpointing_tsgrism(_jail, rtdata, fitsdiff_default_kwargs): +def test_nircam_setpointing_tsgrism(rtdata, fitsdiff_default_kwargs): """ Regression test of the set_telescope_pointing script on a level-1b NIRCam file. """ diff --git a/jwst/regtest/test_nircam_tsimg.py b/jwst/regtest/test_nircam_tsimg.py index b3a4a8aa30..05684588c4 100644 --- a/jwst/regtest/test_nircam_tsimg.py +++ b/jwst/regtest/test_nircam_tsimg.py @@ -11,7 +11,7 @@ @pytest.fixture(scope="module") -def run_pipelines(jail, rtdata_module): +def run_pipelines(rtdata_module): """Run stage 2 and 3 pipelines on NIRCam TSO image data.""" rtdata = rtdata_module @@ -65,7 +65,7 @@ def test_nircam_tsimage_stage3_phot(run_pipelines): @pytest.mark.bigdata -def test_nircam_setpointing_tsimg(_jail, rtdata, engdb, fitsdiff_default_kwargs): +def test_nircam_setpointing_tsimg(rtdata, engdb, fitsdiff_default_kwargs): """ Regression test of the set_telescope_pointing script on a level-1b NIRCam TSO imaging file. diff --git a/jwst/regtest/test_nircam_wfs.py b/jwst/regtest/test_nircam_wfs.py index 4505333457..3b4a0a6262 100644 --- a/jwst/regtest/test_nircam_wfs.py +++ b/jwst/regtest/test_nircam_wfs.py @@ -7,7 +7,7 @@ @pytest.fixture(scope="module") -def run_pipelines(jail, rtdata_module): +def run_pipelines(rtdata_module): """Run the calwebb_wfs-image2 and calwebb_wfs-image3 pipelines on NIRCam WFS&C images. The calwebb_wfs-image3 pipeline is run twice: once with default params and a second time with diff --git a/jwst/regtest/test_nircam_wfss_contam.py b/jwst/regtest/test_nircam_wfss_contam.py index b0d3faf19a..0b50b4935f 100644 --- a/jwst/regtest/test_nircam_wfss_contam.py +++ b/jwst/regtest/test_nircam_wfss_contam.py @@ -5,7 +5,7 @@ @pytest.fixture(scope='module') -def run_wfss_contam(jail, rtdata_module): +def run_wfss_contam(rtdata_module): """Run the wfss_contam step""" rtdata = rtdata_module diff --git a/jwst/regtest/test_niriss_ami3.py b/jwst/regtest/test_niriss_ami3.py index 8e44cef950..ce59cfd78c 100644 --- a/jwst/regtest/test_niriss_ami3.py +++ b/jwst/regtest/test_niriss_ami3.py @@ -7,7 +7,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): """Run calwebb_ami3 on NIRISS AMI data.""" rtdata = rtdata_module rtdata.get_asn("niriss/ami/jw01093-c1000_20221110t003218_ami3_002_asn.json") diff --git a/jwst/regtest/test_niriss_soss.py b/jwst/regtest/test_niriss_soss.py index efb2253194..ef9796d4fa 100644 --- a/jwst/regtest/test_niriss_soss.py +++ b/jwst/regtest/test_niriss_soss.py @@ -5,7 +5,7 @@ @pytest.fixture(scope="module") -def run_tso_spec2(jail, rtdata_module): +def run_tso_spec2(rtdata_module): """Run stage 2 pipeline on NIRISS SOSS data.""" rtdata = rtdata_module @@ -28,7 +28,7 @@ def run_tso_spec2(jail, rtdata_module): @pytest.fixture(scope="module") -def run_tso_spec3(jail, rtdata_module, run_tso_spec2): +def run_tso_spec3(rtdata_module, run_tso_spec2): """Run stage 3 pipeline on NIRISS SOSS data.""" rtdata = rtdata_module # Get the level3 association json file (though not its members) and run @@ -41,7 +41,7 @@ def run_tso_spec3(jail, rtdata_module, run_tso_spec2): @pytest.fixture(scope="module") -def run_atoca_extras(jail, rtdata_module): +def run_atoca_extras(rtdata_module): """Run stage 2 pipeline on NIRISS SOSS data using enhanced modes via parameter settings.""" rtdata = rtdata_module @@ -127,7 +127,7 @@ def test_niriss_soss_extras(rtdata_module, run_atoca_extras, fitsdiff_default_kw @pytest.fixture(scope='module') -def run_extract1d_spsolve_failure(jail, rtdata_module): +def run_extract1d_spsolve_failure(rtdata_module): """ Test coverage for fix to error thrown when spsolve fails to find a good solution in ATOCA and needs to be replaced with a least- @@ -145,7 +145,7 @@ def run_extract1d_spsolve_failure(jail, rtdata_module): @pytest.fixture(scope='module') -def run_extract1d_null_order2(jail, rtdata_module): +def run_extract1d_null_order2(rtdata_module): """ Test coverage for fix to error thrown when all of the pixels in order 2 are flagged as bad. Ensure graceful handling of the diff --git a/jwst/regtest/test_niriss_wfss.py b/jwst/regtest/test_niriss_wfss.py index 6a530273d4..b723690a2f 100644 --- a/jwst/regtest/test_niriss_wfss.py +++ b/jwst/regtest/test_niriss_wfss.py @@ -6,7 +6,7 @@ @pytest.fixture(scope='module') -def run_nis_wfss_spec2(jail, rtdata_module): +def run_nis_wfss_spec2(rtdata_module): """Run the calwebb_spec2 pipeline on NIRISS WFSS exposures""" rtdata = rtdata_module @@ -60,7 +60,7 @@ def test_nis_wfss_spec2(run_nis_wfss_spec2, rtdata_module, fitsdiff_default_kwar @pytest.fixture(scope='module') -def run_nis_wfss_spec3(run_nis_wfss_spec2, rtdata_module, jail): +def run_nis_wfss_spec3(run_nis_wfss_spec2, rtdata_module): """Run the calwebb_spec3 pipeline""" rtdata = rtdata_module diff --git a/jwst/regtest/test_nirspec_brightobj.py b/jwst/regtest/test_nirspec_brightobj.py index 3d5bd65eb0..cc5fedb94b 100644 --- a/jwst/regtest/test_nirspec_brightobj.py +++ b/jwst/regtest/test_nirspec_brightobj.py @@ -12,7 +12,7 @@ @pytest.fixture(scope="module") -def run_tso_spec2_pipeline(jail, rtdata_module, request): +def run_tso_spec2_pipeline(rtdata_module, request): """Run the calwebb_spec2 pipeline performed on NIRSpec fixed-slit data that uses the NRS_BRIGHTOBJ mode (S1600A1 slit) """ diff --git a/jwst/regtest/test_nirspec_exceptions.py b/jwst/regtest/test_nirspec_exceptions.py index b55ecce83d..73a0c70981 100644 --- a/jwst/regtest/test_nirspec_exceptions.py +++ b/jwst/regtest/test_nirspec_exceptions.py @@ -7,7 +7,7 @@ @pytest.mark.bigdata -def test_nirspec_missing_msa_fail(_jail, rtdata, fitsdiff_default_kwargs, caplog): +def test_nirspec_missing_msa_fail(rtdata, fitsdiff_default_kwargs, caplog): """ Test of calwebb_spec2 pipeline performed on NIRSpec MSA exposure that's missing an MSAMETFL. Exception should be raised. @@ -26,7 +26,7 @@ def test_nirspec_missing_msa_fail(_jail, rtdata, fitsdiff_default_kwargs, caplog @pytest.mark.bigdata -def test_nirspec_missing_msa_nofail(_jail, rtdata, fitsdiff_default_kwargs, caplog): +def test_nirspec_missing_msa_nofail(rtdata, fitsdiff_default_kwargs, caplog): """ Test of calwebb_spec2 pipeline performed on NIRSpec MSA exposure that's missing an MSAMETFL. Exception should NOT be raised. @@ -46,7 +46,7 @@ def test_nirspec_missing_msa_nofail(_jail, rtdata, fitsdiff_default_kwargs, capl @pytest.mark.bigdata -def test_nirspec_assignwcs_skip(_jail, rtdata, fitsdiff_default_kwargs, caplog): +def test_nirspec_assignwcs_skip(rtdata, fitsdiff_default_kwargs, caplog): """ Test of calwebb_spec2 pipeline performed on NIRSpec MSA exposure with the AssignWcs step skipped. The pipeline should abort. @@ -66,7 +66,7 @@ def test_nirspec_assignwcs_skip(_jail, rtdata, fitsdiff_default_kwargs, caplog): @pytest.mark.bigdata -def test_nirspec_nrs2_nodata_api(_jail, rtdata, fitsdiff_default_kwargs): +def test_nirspec_nrs2_nodata_api(rtdata, fitsdiff_default_kwargs): """ Test of calwebb_spec2 pipeline performed on NIRSpec IFU exposure that has a filter/grating combination that produces no data on @@ -85,7 +85,7 @@ def test_nirspec_nrs2_nodata_api(_jail, rtdata, fitsdiff_default_kwargs): @pytest.mark.bigdata -def test_nirspec_nrs2_nodata_strun(_jail, rtdata, fitsdiff_default_kwargs, caplog): +def test_nirspec_nrs2_nodata_strun(rtdata, fitsdiff_default_kwargs, caplog): """ Test of calwebb_spec2 pipeline performed on NIRSpec IFU exposure that has a filter/grating combination that produces no data on diff --git a/jwst/regtest/test_nirspec_fs_spec2.py b/jwst/regtest/test_nirspec_fs_spec2.py index 3b3f14ebf1..9b03914620 100644 --- a/jwst/regtest/test_nirspec_fs_spec2.py +++ b/jwst/regtest/test_nirspec_fs_spec2.py @@ -35,7 +35,7 @@ @pytest.fixture(scope="module", params=file_roots) # ids=ids) -def run_pipeline(jail, rtdata_module, request): +def run_pipeline(rtdata_module, request): """Run the calwebb_spec2 pipeline on NIRSpec Fixed-Slit exposures. We currently test the following types of inputs: 1) Full-frame exposure (all slits will be extracted) diff --git a/jwst/regtest/test_nirspec_fs_spec3.py b/jwst/regtest/test_nirspec_fs_spec3.py index c6d9d828e9..10e205e870 100644 --- a/jwst/regtest/test_nirspec_fs_spec3.py +++ b/jwst/regtest/test_nirspec_fs_spec3.py @@ -5,7 +5,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): """ Run the calwebb_spec3 pipeline on NIRSpec Fixed-Slit exposures. """ diff --git a/jwst/regtest/test_nirspec_ifu_spec2.py b/jwst/regtest/test_nirspec_ifu_spec2.py index 5eeb8516a3..14c42ba740 100644 --- a/jwst/regtest/test_nirspec_ifu_spec2.py +++ b/jwst/regtest/test_nirspec_ifu_spec2.py @@ -9,7 +9,7 @@ @pytest.fixture(scope='module') -def run_spec2(jail, rtdata_module): +def run_spec2(rtdata_module): """Run the Spec2Pipeline on a spec2 ASN containing a single exposure""" rtdata = rtdata_module @@ -49,8 +49,8 @@ def test_spec2(run_spec2, fitsdiff_default_kwargs, suffix): truth_path=TRUTH_PATH) -@pytest.fixture() -def run_photom(jail, rtdata): +@pytest.fixture +def run_photom(rtdata): """Run the photom step on an NRS IFU exposure with SRCTYPE=POINT""" # Setup the inputs @@ -75,8 +75,8 @@ def test_photom(run_photom, fitsdiff_default_kwargs): truth_path=TRUTH_PATH) -@pytest.fixture() -def run_extract1d(jail, rtdata): +@pytest.fixture +def run_extract1d(rtdata): """Run the extract_1d step on an NRS IFU cube with SRCTYPE=POINT""" # Setup the inputs diff --git a/jwst/regtest/test_nirspec_ifu_spec3.py b/jwst/regtest/test_nirspec_ifu_spec3.py index ec31756bd2..a2584d4470 100644 --- a/jwst/regtest/test_nirspec_ifu_spec3.py +++ b/jwst/regtest/test_nirspec_ifu_spec3.py @@ -9,7 +9,7 @@ @pytest.fixture(scope='module') -def run_spec3_multi(jail, rtdata_module): +def run_spec3_multi(rtdata_module): """Run Spec3Pipeline""" rtdata = rtdata_module diff --git a/jwst/regtest/test_nirspec_ifu_spec3_emsm.py b/jwst/regtest/test_nirspec_ifu_spec3_emsm.py index d653fa4963..b4316cf43d 100644 --- a/jwst/regtest/test_nirspec_ifu_spec3_emsm.py +++ b/jwst/regtest/test_nirspec_ifu_spec3_emsm.py @@ -9,7 +9,7 @@ @pytest.fixture(scope='module') -def run_spec3_multi_emsm(jail, rtdata_module): +def run_spec3_multi_emsm(rtdata_module): """Run Spec3Pipeline""" rtdata = rtdata_module diff --git a/jwst/regtest/test_nirspec_image2.py b/jwst/regtest/test_nirspec_image2.py index 471f4cfa6a..5bb46cd75a 100644 --- a/jwst/regtest/test_nirspec_image2.py +++ b/jwst/regtest/test_nirspec_image2.py @@ -10,7 +10,7 @@ @pytest.mark.bigdata -def test_nirspec_image2(_jail, rtdata, fitsdiff_default_kwargs): +def test_nirspec_image2(rtdata, fitsdiff_default_kwargs): rtdata.get_data("nirspec/imaging/jw84600010001_02102_00001_nrs2_rate.fits") args = ["calwebb_image2", rtdata.input] diff --git a/jwst/regtest/test_nirspec_imprint.py b/jwst/regtest/test_nirspec_imprint.py index c4c9be6e60..c2c4db14d1 100644 --- a/jwst/regtest/test_nirspec_imprint.py +++ b/jwst/regtest/test_nirspec_imprint.py @@ -9,7 +9,7 @@ @pytest.fixture(scope='module') -def run_spec2(jail, rtdata_module): +def run_spec2(rtdata_module): """Run the Spec2Pipeline on a spec2 ASN containing a single exposure with multiple imprint exposures""" rtdata = rtdata_module diff --git a/jwst/regtest/test_nirspec_irs2_detector1.py b/jwst/regtest/test_nirspec_irs2_detector1.py index 0fba41cec0..8af8bfbcee 100644 --- a/jwst/regtest/test_nirspec_irs2_detector1.py +++ b/jwst/regtest/test_nirspec_irs2_detector1.py @@ -9,7 +9,7 @@ @pytest.fixture(scope="module") -def run_detector1pipeline(rtdata_module, jail): +def run_detector1pipeline(rtdata_module): """Run calwebb_detector1 pipeline on NIRSpec data with IRS2 readout mode.""" rtdata = rtdata_module rtdata.get_data("nirspec/irs2/jw0010010_11010_nrs1_chimera_uncal.fits") diff --git a/jwst/regtest/test_nirspec_masterbackground.py b/jwst/regtest/test_nirspec_masterbackground.py index c706dc7fd6..5c45d41265 100644 --- a/jwst/regtest/test_nirspec_masterbackground.py +++ b/jwst/regtest/test_nirspec_masterbackground.py @@ -13,7 +13,7 @@ @pytest.fixture(scope='module') -def run_spec2_mbkg(jail, rtdata_module): +def run_spec2_mbkg(rtdata_module): """Run Spec2 on MSA data with background slits""" rtdata = rtdata_module @@ -34,7 +34,7 @@ def run_spec2_mbkg(jail, rtdata_module): @pytest.fixture(scope='module') -def run_spec2_mbkg_user(jail, rtdata_module): +def run_spec2_mbkg_user(rtdata_module): """Run Spec2 on MSA data with a user-supplied master bkg spectrum""" rtdata = rtdata_module diff --git a/jwst/regtest/test_nirspec_mos_spec3.py b/jwst/regtest/test_nirspec_mos_spec3.py index 86b7e60bd7..59d9049837 100644 --- a/jwst/regtest/test_nirspec_mos_spec3.py +++ b/jwst/regtest/test_nirspec_mos_spec3.py @@ -5,7 +5,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): """Run calwebb_spec3 on NIRSpec MOS data.""" rtdata = rtdata_module rtdata.get_asn("nirspec/mos/jw00626-o030_20191210t193826_spec3_001_asn.json") diff --git a/jwst/regtest/test_nirspec_subarray.py b/jwst/regtest/test_nirspec_subarray.py index a8d4bfcd67..1114086d05 100644 --- a/jwst/regtest/test_nirspec_subarray.py +++ b/jwst/regtest/test_nirspec_subarray.py @@ -13,7 +13,7 @@ @pytest.fixture(scope="module") -def run_pipeline(jail, rtdata_module): +def run_pipeline(rtdata_module): """Run calwebb_detector1 pipeline on NIRSpec subarray data.""" rtdata = rtdata_module rtdata.get_data("nirspec/fs/nrs1_group_subarray.fits") diff --git a/jwst/regtest/test_schema_editor.py b/jwst/regtest/test_schema_editor.py index a9d3dce74c..bc111133a6 100644 --- a/jwst/regtest/test_schema_editor.py +++ b/jwst/regtest/test_schema_editor.py @@ -23,7 +23,7 @@ @pytest.fixture(scope='module') -def keyword_db(jail, rtdata_module): +def keyword_db(rtdata_module): """Define the keyword database""" rt = rtdata_module @@ -45,7 +45,7 @@ def model_db(): @pytest.fixture(scope='module') -def run_editor_full(jail, keyword_db): +def run_editor_full(tmp_cwd_module, keyword_db): """Just run the editor""" editor = se.Schema_editor( @@ -60,7 +60,7 @@ def run_editor_full(jail, keyword_db): @pytest.mark.bigdata -def test_limit_datamodels_from_file(jail, model_db, keyword_db, rtdata_module): +def test_limit_datamodels_from_file(tmp_cwd_module, model_db, keyword_db, rtdata_module): """Test limiting datamodels from Schema_editor""" # Create the exclusion file. @@ -99,7 +99,7 @@ def test_limit_datamodels(model_db): 'slitmeta.schema.yaml', 'wcsinfo.schema.yaml', ] ) -def test_full_run(jail, schema, run_editor_full, rtdata_module): +def test_full_run(tmp_cwd_module, schema, run_editor_full, rtdata_module): """Check fixed schema files""" rt = rtdata_module rt.output = os.path.join(run_editor_full, schema) @@ -109,7 +109,7 @@ def test_full_run(jail, schema, run_editor_full, rtdata_module): @pytest.mark.bigdata -def test_no_option_warning(jail, keyword_db): +def test_no_option_warning(tmp_cwd_module, keyword_db): """If no operations is given, raise an error""" editor = se.Schema_editor( input=keyword_db diff --git a/jwst/resample/tests/test_resample_step.py b/jwst/resample/tests/test_resample_step.py index 64bd0e8038..08e1fd436b 100644 --- a/jwst/resample/tests/test_resample_step.py +++ b/jwst/resample/tests/test_resample_step.py @@ -293,7 +293,7 @@ def test_pixel_scale_ratio_imaging(nircam_rate, ratio): assert result2.meta.resample.pixel_scale_ratio == ratio -def test_weight_type(nircam_rate, _jail): +def test_weight_type(nircam_rate, tmp_cwd): """Check that weight_type of exptime and ivm work""" im1 = AssignWcsStep.call(nircam_rate, sip_approx=False) _set_photom_kwd(im1) diff --git a/jwst/residual_fringe/tests/test_configuration.py b/jwst/residual_fringe/tests/test_configuration.py index 808c346cd6..d0253333bb 100644 --- a/jwst/residual_fringe/tests/test_configuration.py +++ b/jwst/residual_fringe/tests/test_configuration.py @@ -25,7 +25,7 @@ def miri_image(): return image -def test_call_residual_fringe(_jail, miri_image): +def test_call_residual_fringe(tmp_cwd, miri_image): """ test defaults of step are set up and user input are defined correctly """ # testing the ignore_regions_min @@ -42,7 +42,7 @@ def test_call_residual_fringe(_jail, miri_image): step.run(miri_image) -def test_fringe_flat_applied(_jail, miri_image): +def test_fringe_flat_applied(tmp_cwd, miri_image): miri_image.meta.cal_step.fringe = 'SKIP' residual_fringe_reference_file = None diff --git a/jwst/scripts/okify_regtests.py b/jwst/scripts/okify_regtests.py index 054ee98612..9c0b78ae94 100755 --- a/jwst/scripts/okify_regtests.py +++ b/jwst/scripts/okify_regtests.py @@ -156,9 +156,9 @@ def main(): name = args.job_name # Create and chdir to a temporary directory to store specfiles - with tempfile.TemporaryDirectory() as tmpdir: - print(f'Downloading test logs to {tmpdir}') - with pushd(tmpdir): + with tempfile.TemporaryDirectory() as tmp_path: + print(f'Downloading test logs to {tmp_path}') + with pushd(tmp_path): # Retrieve all the okify specfiles for failed tests. specfiles, asdffiles = artifactory_get_build_artifacts(build, name) diff --git a/jwst/skymatch/tests/test_skymatch.py b/jwst/skymatch/tests/test_skymatch.py index b313cf3893..774b04e2b7 100644 --- a/jwst/skymatch/tests/test_skymatch.py +++ b/jwst/skymatch/tests/test_skymatch.py @@ -363,7 +363,7 @@ def test_skymatch_overlap(nircam_rate, skymethod, subtract, skystat): assert abs(np.mean(im.data[dq_mask]) - lev) < 0.01 -def test_asn_input(nircam_rate, tmpdir): +def test_asn_input(tmp_cwd, nircam_rate, tmp_path): # This is the same test as 'test_skymatch_overlap' with # skymethod='match', subtract=True, skystat='mean' and with memory saving # feature enabled (data loaded from files as needed). @@ -393,9 +393,9 @@ def test_asn_input(nircam_rate, tmpdir): for im, lev in zip(container, levels): im.data += np.random.normal(loc=lev, scale=0.1, size=im.data.shape) - im1_path = str(tmpdir / "skymatch_im1.fits") - im2_path = str(tmpdir / "skymatch_im2.fits") - im3_path = str(tmpdir / "skymatch_im3.fits") + im1_path = "skymatch_im1.fits" + im2_path = "skymatch_im2.fits" + im3_path = "skymatch_im3.fits" im1.write(im1_path) im2.write(im2_path) @@ -407,7 +407,7 @@ def test_asn_input(nircam_rate, tmpdir): product_name='skymatch' ) asn_out_fname, out_serialized = assoc_out.dump(format='json') - asn_out_fname = str(tmpdir / asn_out_fname) + asn_out_fname = asn_out_fname with open(asn_out_fname, "w") as asn_out: asn_out.write(out_serialized) @@ -454,7 +454,7 @@ def test_asn_input(nircam_rate, tmpdir): ) ) ) -def test_skymatch_2x(nircam_rate, tmpdir, skymethod, subtract): +def test_skymatch_2x(tmp_cwd, nircam_rate, tmp_path, skymethod, subtract): # Test that repetitive applications of skymatch produce the same results np.random.seed(1) im1 = nircam_rate.copy() @@ -477,9 +477,9 @@ def test_skymatch_2x(nircam_rate, tmpdir, skymethod, subtract): for im, lev in zip(container, levels): im.data += np.random.normal(loc=lev, scale=0.1, size=im.data.shape) - im1_path = str(tmpdir / "skymatch_im1.fits") - im2_path = str(tmpdir / "skymatch_im2.fits") - im3_path = str(tmpdir / "skymatch_im3.fits") + im1_path = "skymatch_im1.fits" + im2_path = "skymatch_im2.fits" + im3_path = "skymatch_im3.fits" im1.write(im1_path) im2.write(im2_path) @@ -491,7 +491,6 @@ def test_skymatch_2x(nircam_rate, tmpdir, skymethod, subtract): product_name='skymatch' ) asn_out_fname, out_serialized = assoc_out.dump(format='json') - asn_out_fname = str(tmpdir / asn_out_fname) with open(asn_out_fname, "w") as asn_out: asn_out.write(out_serialized) diff --git a/jwst/stpipe/tests/test_asdf_parameters.py b/jwst/stpipe/tests/test_asdf_parameters.py index ad891608bf..ee87b14c1f 100644 --- a/jwst/stpipe/tests/test_asdf_parameters.py +++ b/jwst/stpipe/tests/test_asdf_parameters.py @@ -13,7 +13,7 @@ DEFAULT_RESULT = [DEFAULT_PAR1, DEFAULT_PAR2, False] -def test_asdf_roundtrip_pipeline(_jail): +def test_asdf_roundtrip_pipeline(tmp_cwd): """Save a Pipeline pars and re-instantiate with the save parameters""" # Save the parameters diff --git a/jwst/stpipe/tests/test_pipeline.py b/jwst/stpipe/tests/test_pipeline.py index af60b2161b..96b17a20f7 100644 --- a/jwst/stpipe/tests/test_pipeline.py +++ b/jwst/stpipe/tests/test_pipeline.py @@ -104,7 +104,7 @@ def process(self, *args): return dm -def test_pipeline_from_config_file(_jail): +def test_pipeline_from_config_file(tmp_cwd): config_file_path = join(dirname(__file__), 'steps', 'python_pipeline.cfg') pipe = Pipeline.from_config_file(config_file_path) @@ -114,7 +114,7 @@ def test_pipeline_from_config_file(_jail): pipe.run() -def test_pipeline_python(_jail): +def test_pipeline_python(tmp_cwd): steps = { 'flat_field': {'threshold': 42.0} } @@ -132,7 +132,7 @@ def test_pipeline_python(_jail): pipe.run() -def test_prefetch(_jail, monkeypatch): +def test_prefetch(tmp_cwd, monkeypatch): """Test prefetching""" # Setup mock to crds to flag if the call was made. @@ -172,7 +172,7 @@ def mock(self, parameters, reference_file_types, observatory): assert not mock_get_ref.called -def test_pipeline_from_cmdline_cfg(_jail): +def test_pipeline_from_cmdline_cfg(tmp_cwd): args = [ join(dirname(__file__), 'steps', 'python_pipeline.cfg'), '--steps.flat_field.threshold=47', @@ -186,7 +186,7 @@ def test_pipeline_from_cmdline_cfg(_jail): pipe.run() -def test_pipeline_from_cmdline_class(_jail): +def test_pipeline_from_cmdline_class(tmp_cwd): args = [ 'jwst.stpipe.tests.test_pipeline.MyPipeline', f"--science_filename={join(dirname(__file__), 'data', 'science.fits')}", diff --git a/jwst/stpipe/tests/test_step.py b/jwst/stpipe/tests/test_step.py index dde7088d76..8053e8cf19 100644 --- a/jwst/stpipe/tests/test_step.py +++ b/jwst/stpipe/tests/test_step.py @@ -101,16 +101,16 @@ def test_reftype(cfg_file, expected_reftype): assert step.get_config_reftype() == expected_reftype -def test_saving_pars(tmpdir): +def test_saving_pars(tmp_path): """Save the step parameters from the commandline""" cfg_path = t_path(join('steps', 'jwst_generic_pars-makeliststep_0002.asdf')) - saved_path = tmpdir.join('savepars.asdf') + saved_path = os.path.join(tmp_path, 'savepars.asdf') step = Step.from_cmdline([ cfg_path, '--save-parameters', str(saved_path) ]) - assert saved_path.check() + assert os.path.exists(saved_path) with asdf.open(t_path(join('steps', 'jwst_generic_pars-makeliststep_0002.asdf'))) as af: original_config = StepConfig.from_asdf(af) @@ -597,7 +597,7 @@ def test_print_configspec(): step.print_configspec() -def test_call_with_config(caplog, _jail): +def test_call_with_config(caplog, tmp_cwd): """Test call using a config file with substeps In particular, from JP-1482, there was a case where a substep parameter diff --git a/jwst/straylight/tests/test_straylight_step.py b/jwst/straylight/tests/test_straylight_step.py index ee5eb07365..b011a458c3 100644 --- a/jwst/straylight/tests/test_straylight_step.py +++ b/jwst/straylight/tests/test_straylight_step.py @@ -26,7 +26,7 @@ def miri_mrs_short_tso(): return image -def test_call_straylight_mrsshort_tso(_jail, miri_mrs_short_tso): +def test_call_straylight_mrsshort_tso(tmp_cwd, miri_mrs_short_tso): """Test step is skipped for MRS IFUSHORT TSO data""" result = StraylightStep.call(miri_mrs_short_tso) assert result.meta.cal_step.straylight == 'SKIPPED' diff --git a/jwst/tests/test_infrastructure.py b/jwst/tests/test_infrastructure.py index 7f3615277e..b81c57ff44 100644 --- a/jwst/tests/test_infrastructure.py +++ b/jwst/tests/test_infrastructure.py @@ -36,7 +36,7 @@ def test_word_precision_check(): ('*.fits', 0) ], ids=['all', 'txt', 'fits'] ) -def test_data_glob_local(glob_filter, nfiles, _jail): +def test_data_glob_local(glob_filter, nfiles, tmp_cwd): """Test working of local globbing Parameters diff --git a/jwst/wfs_combine/tests/test_wfs_combine.py b/jwst/wfs_combine/tests/test_wfs_combine.py index 6ff1c9f1cd..dac3a753d0 100644 --- a/jwst/wfs_combine/tests/test_wfs_combine.py +++ b/jwst/wfs_combine/tests/test_wfs_combine.py @@ -101,7 +101,7 @@ def wfs_association(tmp_path_factory): (1, 3, SATURATED, SATURATED, 2, SATURATED), ] ) -def test_create_combined(_jail, wfs_association, +def test_create_combined(tmp_cwd, wfs_association, data1, data2, dq1, dq2, result_data, result_dq): path_asn, path1, path2 = wfs_association diff --git a/pyproject.toml b/pyproject.toml index 6d6077e728..188c0c9d76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", ] dependencies = [ - "asdf>=2.15.1,<4", + "asdf>=3.1.0,<4", "astropy>=5.3", "BayesicFitting>=3.0.1", "crds>=11.17.14", @@ -232,7 +232,10 @@ results_root = "jwst-pipeline-results" text_file_format = "rst" doctest_plus = "enabled" doctest_rst = "enabled" -addopts = "--show-capture=no --report-crds-context" +addopts = ["-p no:legacypath", + "--show-capture=no", + "--report-crds-context", +] filterwarnings = [ "error::ResourceWarning", "ignore:Models in math_functions:astropy.utils.exceptions.AstropyUserWarning",