Skip to content

Commit a9ea40f

Browse files
committed
TST: ensure __all__ is complete
1 parent 88ce789 commit a9ea40f

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎astropy/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"samp",
2727
"stats",
2828
"table",
29+
"tests",
2930
"time",
3031
"timeseries",
3132
"uncertainty",

‎astropy/tests/tests/test_imports.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import pkgutil
44
import subprocess
55
import sys
6+
from pathlib import Path
67
from textwrap import dedent
8+
from types import ModuleType
9+
10+
import astropy
711

812

913
def test_imports():
@@ -46,3 +50,20 @@ def test_toplevel_lazy_imports():
4650
assert 'astropy.units' in sys.modules
4751
""")
4852
assert subprocess.check_call([sys.executable, "-c", cmd]) == 0
53+
54+
55+
def test_completeness_toplevel__all__():
56+
# Implicitly check that all items in __all__ exist.
57+
all_items = {getattr(astropy, attr) for attr in astropy.__all__}
58+
# Verify that the list of modules in __all__ is complete.
59+
module_names = {
60+
item.__name__.partition(".")[2]
61+
for item in all_items
62+
if isinstance(item, ModuleType)
63+
}
64+
module_dirs = {
65+
f.name
66+
for f in Path(astropy.__file__).parent.glob("[a-z]*")
67+
if f.is_dir() and f.name != "extern"
68+
}
69+
assert module_names == module_dirs

0 commit comments

Comments
 (0)