Created
December 8, 2017 12:53
-
-
Save andriykohut/6145c4403657639676c47ff545fabf38 to your computer and use it in GitHub Desktop.
Dynamicly load modules
This file contains hidden or 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
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