Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pytest.importorskip on test utils #116

Closed

Conversation

zacharyburnett
Copy link
Collaborator

@zacharyburnett zacharyburnett commented Oct 10, 2023

closes #114

use pytest.importorskip to import util to make test image, to keep abstract model tests from failing if roman_datamodels is not installed

def test_roman_datamodel():
roman_datamodels = pytest.importorskip("roman_datamodels.datamodels")
import roman_datamodels.tests.util as rutil
roman_image_tree = rutil.mk_level2_image()
image_model = roman_datamodels.ImageModel(roman_image_tree)
assert isinstance(image_model, AbstractDataModel)

@zacharyburnett zacharyburnett added the no-changelog-entry-needed does not require an entry in `CHANGES.rst` label Oct 10, 2023
@zacharyburnett zacharyburnett self-assigned this Oct 10, 2023
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

All modified lines are covered by tests ✅

📢 Thoughts on this report? Let us know!.

@@ -9,7 +9,7 @@

def test_roman_datamodel():
roman_datamodels = pytest.importorskip("roman_datamodels.datamodels")
import roman_datamodels.tests.util as rutil
rutil = pytest.importorskip("roman_datamodels.tests.util")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I no longer see the roman_datamodels.tests.util submodule in roman_datamodels. mk_level2_image is available from roman_datamodels.maker_utils.

Suggested change
rutil = pytest.importorskip("roman_datamodels.tests.util")
rutil = pytest.importorskip("roman_datamodels.maker_utils")

What options are there for updating the stpipe CI to run this test? At the moment I'm failing to find a run that installs roman_datamodels and runs the stpipe tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a datamodels install target which installs stdatamodels and roman_datamodels. One of the test cases can specify that additional target.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why roman_datamodels is not mentioned in test dependencies:

stpipe/pyproject.toml

Lines 22 to 35 in 5369e85

[project.optional-dependencies]
docs = [
'numpydoc',
'sphinx',
'sphinx-automodapi',
'sphinx-rtd-theme',
'stsci-rtd-theme',
'tomli; python_version <"3.11"',
]
test = [
'pytest >=7.0.0',
'pytest-doctestplus >=0.10.0',
]

And not in install dependencies:

stpipe/pyproject.toml

Lines 14 to 19 in 5369e85

dependencies = [
'asdf>=2.13',
'crds>=7.4.1.3',
'astropy>=5.0.4',
'importlib_metadata>=4.11.4',
]

@zacharyburnett
Copy link
Collaborator Author

superseded by #118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog-entry-needed does not require an entry in `CHANGES.rst`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing test: ModuleNotFoundError: No module named 'roman_datamodels.tests'
4 participants