Skip to content

Commit

Permalink
remove calls to Step.closeout in tests (#8428)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed May 9, 2024
2 parents b551294 + 781e0e0 commit b37c815
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
22 changes: 7 additions & 15 deletions jwst/stpipe/tests/test_saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def test_save_step_default(mk_tmp_dirs):
data_fn_path
]

step = Step.from_cmdline(args)
step.closeout()
Step.from_cmdline(args)

fname = 'flat_stepwithmodel.fits'
assert path.isfile(fname)
Expand All @@ -62,8 +61,7 @@ def test_save_step_withoutput(mk_tmp_dirs):
'--output_file=' + output_file
]

step = Step.from_cmdline(args)
step.closeout()
Step.from_cmdline(args)

output_path, output_ext = path.splitext(output_file)
assert path.isfile(output_path + '_stepwithmodel' + output_ext)
Expand All @@ -82,8 +80,7 @@ def test_save_step_withoutputsuffix(mk_tmp_dirs):
'--output_file=' + output_file
]

step = Step.from_cmdline(args)
step.closeout()
Step.from_cmdline(args)

assert path.isfile(actual_output_file)

Expand All @@ -98,8 +95,7 @@ def test_save_step_withdir(mk_tmp_dirs):
'--output_dir=' + tmp_data_path
]

step = Step.from_cmdline(args)
step.closeout()
Step.from_cmdline(args)

output_fn_path = path.join(
tmp_data_path,
Expand All @@ -120,8 +116,7 @@ def test_save_step_withdir_environment(mk_tmp_dirs):
'--output_dir=$TSSWE_OUTPATH'
]

step = Step.from_cmdline(args)
step.closeout()
Step.from_cmdline(args)

output_fn_path = path.join(
tmp_data_path,
Expand All @@ -143,8 +138,7 @@ def test_save_step_withdir_withoutput(mk_tmp_dirs):
'--output_file=' + output_file
]

step = Step.from_cmdline(args)
step.closeout()
Step.from_cmdline(args)

output_path, output_ext = path.splitext(output_file)
output_fn_path = path.join(
Expand Down Expand Up @@ -195,13 +189,11 @@ def test_save_container_withfile(mk_tmp_dirs):
'--output_file=tscwf.fits',
]

step = Step.from_cmdline(args)
Step.from_cmdline(args)

assert path.isfile('tscwf_0_stepwithcontainer.fits')
assert path.isfile('tscwf_1_stepwithcontainer.fits')

step.closeout()


def test_save_pipeline_default(mk_tmp_dirs):
"""Default save should be current working directory"""
Expand Down
4 changes: 1 addition & 3 deletions jwst/stpipe/tests/test_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ 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 = os.path.join(tmp_path, 'savepars.asdf')
step = Step.from_cmdline([
Step.from_cmdline([
cfg_path,
'--save-parameters',
str(saved_path)
Expand All @@ -120,8 +120,6 @@ def test_saving_pars(tmp_path):
config = StepConfig.from_asdf(af)
assert config.parameters == original_config.parameters

step.closeout()


@pytest.mark.parametrize(
'step_obj, expected',
Expand Down

0 comments on commit b37c815

Please sign in to comment.