Testing Ansible content with plain pytest: pytest-ansible plugin end of life in December 2026

You no longer need an extra plugin layer to test Ansible collections with pytest. Over the past decade, pytest-ansible bridged critical gaps between pytest and Ansible. Today, modern Ansible tooling (tox-ansible, Molecule, and Ansible Development Environment) handles collection pathing and test execution natively. Because plain pytest works out of the box, we are retiring pytest-ansible with upstream end of life planned for December 2026.

Why now

When pytest-ansible started in 2014, it solved a real need: accessing Ansible inventory, module calls, unit-test path injection, and Molecule scenarios from inside pytest. Dedicated tools now handle each of those workflows natively without extra wrapper fixtures. Retiring the plugin removes a redundant layer from your test stack, and the project README shows how to switch to direct, native patterns.

What changed in tox-ansible

tox-ansible v26.11.1 now sets up collection paths in the test environments it creates. It drops the automatic pytest-ansible install and stops passing --ansible-unit-inject-only. If your own test command uses that flag, check how it finds the collection before removing it. If CI breaks, temporarily pin the last working tox-ansible version. For direct plugin installs, pin a known-working pytest-ansible release while you migrate.

Check your collection before upgrading. Look in test requirements and CI for the pytest-ansible dependency. Check test code and commands for pytest_ansible imports, plugin fixtures, and options. Verify how names like ansible_host are used before editing them. Run your usual CI tests after migrating. You could use this optional AI skill to verify.

What to use instead

Collection unit tests. Use Ansible Development Environment (ADE) with plain pytest. Check for plugin-specific options in your test commands and update those commands when you remove the dependency.

Molecule scenarios. Starting with ansible-creator v26.12.0 , new collections get a starter integration test that runs molecule test --all directly. If your existing tests use molecule_scenario, switch to that command or the Molecule test type in tox-ansible.

Inventory and module helpers. Use ansible-inventory --list with parametrized pytest tests to iterate over hosts or groups. For module calls, use a small helper in your repository or a Molecule scenario. The project README has examples for replacing fixtures such as ansible_host and ansible_module.

What to expect during the transition

Until end of life, maintainers will prioritize migration documentation and may address security issues or critical regressions at their discretion. We plan to end upstream releases and compatibility updates after December 2026. We also plan to remove pytest-ansible as a direct dependency of the upstream ansible-dev-tools bundle in a future release. We’ll share the AAP removal timing for DevTools packages and containers once the release is confirmed.

Tell us what is blocking your migration

If your tests break after upgrading or you depend on a fixture or flag that the guide doesn’t cover, please reply here with the tool versions, the fixture or flag you use, and a short description of what failed. That will help us improve the guidance.

Thank you to everyone who has used the plugin, reported issues, contributed fixes, or helped maintain it.

2 Likes