Skip to content

Imports from ansible_collections don't work in conftest modules. #62113

@mattclay

Description

@mattclay
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: webknjaz/fqcn_conftest_repro@b07826c

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects_2.10This issue/PR affects Ansible v2.10bugThis issue/PR relates to a bug.support:coreThis issue/PR relates to code supported by the Ansible Engineering Team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions