##### SUMMARY

(converted from project card created by @webknjaz)

When conftest in unit test contains something like `from ansible_collections.yum_unit_test_migration_spec.yum_collection.tests.unit.compat.mock import patch`, it will result in `E   ModuleNotFoundError: No module named 'ansible_collections'`.

The workaround is to add a boilerplate `conftest.py` into tests root: https://github.com/webknjaz/fqcn_conftest_repro/commit/b07826c54e01c6965cb63aa0a8cada602a311911

##### COMPONENT NAME

ansible-test

##### ANSIBLE VERSION

devel

##### CONFIGURATION

N/A

##### OS / ENVIRONMENT

N/A

##### STEPS TO REPRODUCE

Repro: https://github.com/webknjaz/fqcn_conftest_repro/tree/77347551f5fdd5185b26c752074878ea37055b77

Failure demo: https://github.com/webknjaz/fqcn_conftest_repro/runs/216648897#step:5:41

Hack demo: https://github.com/webknjaz/fqcn_conftest_repro/runs/216654164#step:5:65

##### EXPECTED RESULTS

Tests pass.

##### ACTUAL RESULTS

Tests fail.

if not coverage:
        return
    import gc
    import os
    coverage_instances = []
    for obj in gc.get_objects():
        if isinstance(obj, coverage.Coverage):
            coverage_instances.append(obj)
    if not coverage_instances:
        coverage_config = os.environ.get('COVERAGE_CONF')
        if not coverage_config:
            return
        coverage_output = os.environ.get('COVERAGE_FILE')
        if not coverage_output:
            return
        cov = coverage.Coverage(config_file=coverage_config)
        coverage_instances.append(cov)
    else:
        cov = None
    
    os_exit = os._exit  
    def coverage_exit(*args, **kwargs):
        for instance in coverage_instances:
            instance.stop()
            instance.save()
        os_exit(*args, **kwargs)
    os._exit = coverage_exit  
    if cov:
        cov.start()