Last active
August 29, 2015 14:23
-
-
Save briancline/6b80a79e5d64d8935a4b to your computer and use it in GitHub Desktop.
Unit test to import all Python package modules
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
import pkgutil | |
import unittest | |
import mypkg | |
class TestModule(unittest.TestCase): | |
def setUp(self): | |
pass | |
def test_import_all_modules(self): | |
skip_modules = [] | |
module_path = mypkg.__path__ | |
for loader, module_name, is_pkg in pkgutil.walk_packages(module_path): | |
if module_name in skip_modules: | |
continue | |
print('loading module %s' % module_name) | |
module = loader.find_module(module_name).load_module(module_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment