Commit 38c341a039 for bind
commit 38c341a039edf4740083d9f2fcc422abe9fc2fa4
Author: Nicki Křížek <nicki@isc.org>
Date: Fri Nov 20 13:21:40 2026 +0000
Load the isctest submodules on first use
The import of the isctest package also imported all its submodules.
These submodules import dnspython, hypothesis and the cryptography
bindings. This took approximately 0.2 seconds. A tests.sh script
starts each standalone tool (python -m isctest.tools.<name>) as a new
process. Each call took this much time, but the tools do not use the
submodules.
The package now imports a submodule when the caller uses it for the
first time.
isctest.text is now in the list of submodules. Some tests use it and
do not import it. This was possible only because isctest.log
imported it.
diff --git a/bin/tests/system/isctest/__init__.py b/bin/tests/system/isctest/__init__.py
index 28efa2f00d..817c71149c 100644
--- a/bin/tests/system/isctest/__init__.py
+++ b/bin/tests/system/isctest/__init__.py
@@ -9,39 +9,68 @@
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-from . import ( # pylint: disable=redefined-builtin
- algorithms,
- check,
- hypothesis,
- instance,
- kasp,
- log,
- query,
- rndc,
- run,
- template,
- transfer,
- vars,
- zone,
-)
-
-# isctest.mark module is intentionally NOT imported, because it relies on
-# environment variables which might not be set at the time of import of the
-# `isctest` package. To use the marks, manual `import isctest.mark` is needed
-# instead.
+from types import ModuleType
+from typing import TYPE_CHECKING
+
+import importlib
+
+if TYPE_CHECKING:
+ from . import ( # pylint: disable=redefined-builtin
+ algorithms,
+ asyncserver,
+ check,
+ hypothesis,
+ instance,
+ kasp,
+ log,
+ mark,
+ name,
+ query,
+ rndc,
+ run,
+ template,
+ text,
+ tools,
+ transfer,
+ util,
+ vars,
+ zone,
+ )
__all__ = [
"algorithms",
+ "asyncserver",
"check",
"hypothesis",
"instance",
"kasp",
"log",
+ "mark",
+ "name",
"query",
"rndc",
"run",
"template",
+ "text",
+ "tools",
"transfer",
+ "util",
"vars",
"zone",
]
+
+
+def __dir__() -> list[str]:
+ return __all__
+
+
+def __getattr__(name: str) -> ModuleType:
+ """
+ Import a submodule from the list above when the caller uses it for
+ the first time. The import of all the submodules takes much time,
+ and a standalone tool (python -m isctest.tools.<name>) does not use
+ them.
+ """
+ if name in __all__:
+ return importlib.import_module(f"{__name__}.{name}")
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")