This script traverses through the whole module tree starting from my_parent_module
to find all python files that are
contained inside a folder / module named tests
(can be changed).
This script finds all modules / files that contain the module_to_search
in their module path (my_parent_module.network.tests
).
For that to work, the tests
folder must a valid python module. Which means, that at least an
empty __init__.py
must be included.
├── my_parent_module
│ ├── __init__.py
│ ├── network
│ │ ├── __init__.py
│ │ ├── network.py
│ │ └── tests
│ │ ├── __init__.py
│ │ └── network_test.py
│ └── security
│ ├── __init__.py
│ ├── CRC.py
│ └── tests
│ ├── __init__.py
│ └── CRC_test.py
└── tests.py
After executing this script starting from tests.py
all classes, functions, ... from CRC_test.py
, network_test.py
and the corresponding
__init__.py
s are loaded into globals()
and can now be accessed in the context of tests.py
.