Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mattclay opened this issue Sep 11, 2019 · 2 comments · Fixed by #62119
Closed

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

mattclay opened this issue Sep 11, 2019 · 2 comments · Fixed by #62119
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@mattclay
Copy link
Member

mattclay commented Sep 11, 2019

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.

@mattclay mattclay created this issue from a note in Testing Collections (To do) Sep 11, 2019
@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 feature This issue/PR relates to a feature request. needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 11, 2019
@ansible ansible deleted a comment from ansibot Sep 11, 2019
@ansible ansible deleted a comment from ansibot Sep 11, 2019
@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label Sep 11, 2019
@mattclay
Copy link
Member Author

!component =bin/ansible-test

@mattclay
Copy link
Member Author

This is caused by pytest loading conftest modules during test runs before loading plugins specified on the command line, making the collection loader unavailable to provide support for imports.

@mattclay mattclay added bug This issue/PR relates to a bug. and removed needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. feature This issue/PR relates to a feature request. labels Sep 11, 2019
@mattclay mattclay moved this from To do to In progress in Testing Collections Sep 11, 2019
Testing Collections automation moved this from In progress to Done Sep 11, 2019
@ansible ansible locked and limited conversation to collaborators Oct 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants