Skip to content

Commit

Permalink
Remove upper pytest pin, switch globals use to fixture in stpipe test (
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Mar 16, 2024
2 parents 77c4966 + 2fb073e commit 7ddcbc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
22 changes: 4 additions & 18 deletions jwst/stpipe/tests/test_crds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from os.path import join, dirname, basename
import shutil
import tempfile

import pytest

Expand All @@ -9,19 +7,6 @@
from jwst.stpipe import Step
import crds

TMP_DIR = None
TMP_FITS = None


def setup():
global TMP_DIR, TMP_FITS
TMP_DIR = tempfile.mkdtemp()
TMP_FITS = join(TMP_DIR, 'tmp.fits')


def teardown():
shutil.rmtree(TMP_DIR)


class CrdsStep(Step):
reference_file_types = ['flat']
Expand Down Expand Up @@ -53,7 +38,7 @@ def _run_flat_fetch_on_dataset(dataset_path):
assert basename(step.ref_filename) == "jwst_nircam_flat_0296.fits"


def test_crds_step_override():
def test_crds_step_override(tmp_path):
"""Run CRDS step with override parameter bypassing CRDS lookup."""
from stdatamodels.jwst import datamodels

Expand All @@ -63,9 +48,10 @@ def test_crds_step_override():
assert step.ref_filename.endswith('data/flat.fits')
assert result.meta.ref_file.flat.name.endswith('flat.fits')

result.to_fits(TMP_FITS)
fn = tmp_path / 'tmp.fits'
result.to_fits(fn)

with fits.open(TMP_FITS) as hdulist:
with fits.open(fn) as hdulist:
assert hdulist[0].header['R_FLAT'].endswith('flat.fits')


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test = [
"colorama>=0.4.1",
"readchar>=3.0",
"ruff",
"pytest>=6.0.0,<8.1.0",
"pytest>=6.0.0",
"pytest-cov>=2.9.0",
"pytest-doctestplus>=0.10.0",
"requests_mock>=1.0",
Expand Down

0 comments on commit 7ddcbc7

Please sign in to comment.