def _iter_all_modules(package, prefix="<STR_LIT>"):
import os<EOL>import pkgutil<EOL>if type(package) is not str:<EOL><INDENT>path, prefix = package.__path__[<NUM_LIT:0>], package.__name__ + "<STR_LIT:.>"<EOL><DEDENT>else:<EOL><INDENT>path = package<EOL><DEDENT>for _, name, is_package in pkgutil.iter_modules([path]):<EOL><INDENT>if is_package:<EOL><INDENT>for m in _iter_all_modules(os.path.join(path, name), prefix=name + "<STR_LIT:.>"):<EOL><INDENT>yield prefix + m<EOL><DEDENT><DEDENT>else:<EOL><INDENT>yield prefix + name<EOL><DEDENT><DEDENT>
Iterates over the names of all modules that can be found in the given
package, recursively.
Example:
    _iter_all_modules(_pytest) ->
        ['_pytest.assertion.newinterpret',
         '_pytest.capture',
         '_pytest.core',
         ...
        ]