def test_imports():
 from ...utils import find_current_module
 pkgornm = find_current_module(1).__name__.split(u'.')[0]
 if isinstance(pkgornm, six.string_types):
  package = pkgutil.get_loader(pkgornm).load_module(pkgornm)
 elif (isinstance(pkgornm, types.ModuleType) and (u'__init__' in pkgornm.__file__)):
  package = pkgornm
 else:
  msg = u'test_imports is not determining a valid package/package name'
  raise TypeError(msg)
 if hasattr(package, u'__path__'):
  pkgpath = package.__path__
 elif hasattr(package, u'__file__'):
  pkgpath = os.path.split(package.__file__)[0]
 else:
  raise AttributeError(u'package to generate config items for does not have __file__ or __path__')
 if six.PY2:
  excludes = _py3_packages
 else:
  excludes = _py2_packages
 prefix = (package.__name__ + u'.')
 def onerror(name):
  if (not any((name.startswith(excl) for excl in excludes))):
   raise
 for (imper, nm, ispkg) in pkgutil.walk_packages(pkgpath, prefix, onerror=onerror):
  imper.find_module(nm)

def test_imports ( ) : from ... utils import find_current_module pkgornm = find_current_module ( 1 ) . __name__ . split ( u'.' ) [ 0 ] if isinstance ( pkgornm , six . string_types ) : package = pkgutil . get_loader ( pkgornm ) . load_module ( pkgornm ) elif ( isinstance ( pkgornm , types . ModuleType ) and ( u'__init__' in pkgornm . __file__ ) ) : package = pkgornm else : msg = u'test_imports is not determining a valid package/package name' raise TypeError ( msg ) if hasattr ( package , u'__path__' ) : pkgpath = package . __path__ elif hasattr ( package , u'__file__' ) : pkgpath = os . path . split ( package . __file__ ) [ 0 ] else : raise AttributeError ( u'package to generate config items for does not have __file__ or __path__' ) if six . PY2 : excludes = _py3_packages else : excludes = _py2_packages prefix = ( package . __name__ + u'.' ) def onerror ( name ) : if ( not any ( ( name . startswith ( excl ) for excl in excludes ) ) ) : raise for ( imper , nm , ispkg ) in pkgutil . walk_packages ( pkgpath , prefix , onerror = onerror ) : imper . find_module ( nm )
this just imports all modules in astropy .