From 67f3ca17ddc878515daf99f7949bde77eb8f30f0 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 26 Mar 2019 02:17:33 -0400 Subject: [PATCH] test: add test to try importing every file The testsuite does not currently exercise every file, but we can at least try importing it to make sure it isn't obviously broken. This additionally helps to iterate through python3 syntax-level incompatibilities. --- src/calibre/test_build.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/calibre/test_build.py b/src/calibre/test_build.py index 2ba6492114..397299264b 100644 --- a/src/calibre/test_build.py +++ b/src/calibre/test_build.py @@ -73,6 +73,27 @@ class BuildTest(unittest.TestCase): from html5_parser import parse parse('

xxx') + def test_imports(self): + import importlib + exclude = ['dbus_export.demo', 'dbus_export.gtk', 'upstream'] + if not iswindows: + exclude.extend(['iphlpapi', 'windows', 'winreg', 'winusb']) + if not isosx: + exclude.append('osx') + if not islinux: + exclude.extend(['dbus', 'linux']) + for root, dirs, files in os.walk('src/calibre'): + for dir in dirs: + if not os.path.isfile(os.path.join(root, dir, '__init__.py')): + dirs.remove(dir) + for file in files: + file, ext = os.path.splitext(file) + if ext != '.py': + continue + name = '.'.join(root.split(os.path.sep)[1:] + [file]) + if not any(x for x in exclude if x in name): + importlib.import_module(name) + def test_plugins(self): exclusions = set() if is_ci: