Getting scripts within packages under the Scripting Project Library

What is the proper way to get scripts within packages under the Scripting Project Library?

My objective is to create a unit test runner and find all the scripts, regardless of their location in the Scripting Project Library with the suffix “_tests” and run them.

Currently, I use the following to find all the modules using the following:

#  The list of “roots” in the project
_SYS_MODULES = list(sys.modules.keys())

It works, but it I can only get the scripts in the top level, not contained within packages.

I'd like to use the following structure under the Scripting tree:

Scripting
- Project Library
    - test_scripts
        - test_runner
    - category_a
        - logic_1
        - logic_1_tests
    - category_b
        - logic_2
        - logic_2_tests

Have you explored the objects with the Python builtins dir, type, and getattr?

3 Likes