-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #343 from AstarVienna/hb/importall
Add test to see whether all Python files can be imported.
- Loading branch information
Showing
6 changed files
with
40 additions
and
2,074 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,987 changes: 0 additions & 1,987 deletions
1,987
scopesim/tests/profiling/profile_hawki_results.txt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Test whether all Python files can be imported.""" | ||
import importlib.util | ||
import time | ||
from pathlib import Path | ||
|
||
import scopesim | ||
|
||
|
||
def test_import_all(): | ||
"""Test whether all Python files can be imported. | ||
This ensures that all files are included in the code coverage. | ||
""" | ||
for name_path_scopesim in scopesim.__path__: | ||
path_scopesim = Path(name_path_scopesim) | ||
fns_python = path_scopesim.glob("**/*.py") | ||
for fn in fns_python: | ||
name_package = ".".join(fn.relative_to(path_scopesim.parent).with_suffix("").parts) | ||
time_1 = time.time() | ||
importlib.import_module(name_package) | ||
time_2 = time.time() | ||
time_delta = time_2 - time_1 | ||
msg = f"{name_package} takes {time_delta} seconds to import" | ||
# Assert the package is quick to import, because this can highlight | ||
# broken packages. Requires running this test in isolation. | ||
assert time_delta < 0.2, msg |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters