1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
# Copyright (C) 2022 Nathan Sime
#
# This file is part of DOLFINx (https://www.fenicsproject.org)
#
# SPDX-License-Identifier: LGPL-3.0-or-later
import importlib
import pkgutil
import pytest
def collect_pkg_modules_recursive(name):
module = importlib.import_module(name)
submodules = list(a.name for a in pkgutil.iter_modules(module.__path__, prefix=f"{name}."))
subpackages = list(
a.name for a in pkgutil.iter_modules(module.__path__, prefix=f"{name}.") if a.ispkg
)
for subpackage in subpackages:
pkg_submodules = collect_pkg_modules_recursive(subpackage)
submodules.extend(pkg_submodules)
return list(set(submodules))
@pytest.mark.skip("Test fails when using shared linking with nanobind")
def test_all_implemented():
"""flake8 does not catch its warning code F822: whether the public API
offered by the members of __all__ are implemented. We therefore manually
check.
"""
module_names = collect_pkg_modules_recursive("dolfinx")
for module_name in module_names:
module = importlib.import_module(module_name)
if hasattr(module, "__all__"):
for member in module.__all__:
assert hasattr(module, member)
|