Skip to content

Instantly share code, notes, and snippets.

@andriykohut
Created December 8, 2017 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andriykohut/6145c4403657639676c47ff545fabf38 to your computer and use it in GitHub Desktop.
Save andriykohut/6145c4403657639676c47ff545fabf38 to your computer and use it in GitHub Desktop.
Dynamicly load modules
import pkgutil
def get_test_routes():
from tests import routes
test_modules = []
for importer in pkgutil.iter_modules(routes.__path__):
if importer.ispkg is False:
print(f"Loading test routes for {importer.name}")
test_modules.append(importer.module_finder.find_module(importer.name).load_module(importer.name))
return test_modules
test_modules = get_test_routes()
for mod in test_modules:
print(len(mod.tests))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment