| 1 |
import os.path |
| 2 |
import pkgutil |
| 3 |
from unittest import TestCase, TestSuite |
| 4 |
|
| 5 |
|
| 6 |
class TestImports(TestCase): |
| 7 |
def __init__(self, mod_name): |
| 8 |
name = f"test_{mod_name.replace('.', '_')}_import" |
| 9 |
|
| 10 |
def f(): |
| 11 |
__import__(mod_name) |
| 12 |
|
| 13 |
setattr(self, name, f) |
| 14 |
super().__init__(name) |
| 15 |
|
| 16 |
|
| 17 |
def load_tests(*_args): |
| 18 |
test_cases = TestSuite() |
| 19 |
home, subpath = os.path.dirname(__file__).rsplit("/test/", 1) |
| 20 |
for package in pkgutil.iter_modules([f"{home}/blueman/{subpath}"], f"blueman.{subpath.replace('/', '.')}."): |
| 21 |
test_cases.addTest(TestImports(package.name)) |
| 22 |
|
| 23 |
assert test_cases.countTestCases() > 0 |
| 24 |
|
| 25 |
return test_cases |