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

Add test to see whether all Python files can be imported. #343

Merged
merged 8 commits into from
Jan 17, 2024
4 changes: 2 additions & 2 deletions scopesim/detector/nghxrg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# import warnings

import numpy as np
from scipy.ndimage.interpolation import zoom
from scipy.ndimage import zoom
from astropy.io import fits
from astropy.stats.funcs import median_absolute_deviation as mad

Expand Down Expand Up @@ -199,7 +199,7 @@
"""

# Configure depending on mode setting
if mode is 'pink':
if mode == 'pink':

Check warning on line 202 in scopesim/detector/nghxrg.py

View check run for this annotation

Codecov / codecov/patch

scopesim/detector/nghxrg.py#L202

Added line #L202 was not covered by tests
nstep = 2*self.nstep
f = self.f2
p_filter = self.p_filter2
Expand Down
33 changes: 33 additions & 0 deletions scopesim/tests/test_import_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Test whether all Python files can be imported."""
import importlib.util
import pkgutil

import scopesim


def import_submodules(package):
""" Import all submodules of a module, recursively, including subpackages

:param package: package (name or actual module)
:type package: str | module
:rtype: dict[str, types.ModuleType]

https://stackoverflow.com/a/25562415
"""
if isinstance(package, str):
package = importlib.import_module(package)
results = {}
for loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
full_name = package.__name__ + '.' + name
results[full_name] = importlib.import_module(full_name)
if is_pkg:
results.update(import_submodules(full_name))
return results


def test_import_all():
"""Test whether all Python files can be imported.

This ensures that all files are included in the code coverage.
"""
import_submodules(scopesim)
51 changes: 0 additions & 51 deletions scopesim/tests/tests_integrations/tst_ScopeSim_MET_LSS.py

This file was deleted.

Loading