Open 0xdeadbeefJERKY opened 6 months ago
I can't reproduce this with Python 3.12.3 or 3.10.9. I set up the Python virtual environment with, e.g.:
$ pyenv virtualenv 3.10.9 ansible-role-amazon-ssm-agent
$ pyenv local ansible-role-amazon-ssm-agent
$ pip install --upgrade pip setuptools wheel && pip install --upgrade --upgrade-strategy=eager -r requirements-dev.txt && pre-commit install
(This is analogous to what the setup-env
script does.) Then I run molecule test
and witness no issues.
@0xdeadbeefJERKY - Can you help me to reproduce the behavior you are seeing? From your output it does not appear that you are working from a Python local environment, as described in CONTRIBUTING.md.
@jsf9k I just reproduced the issue again by doing the following:
git clone https://github.com/cisagov/ansible-role-amazon-ssm-agent
cd ansible-role-amazon-ssm-agent
pyenv global 3.10
./setup-env
molecule test
This is being done from an Ubuntu 22.04 machine. I noticed that pytest-testinfra
isn't being pinned to a specific version. Maybe there were some behavioral changes introduced in a more recent version?
❯ ansible --version
ansible [core 2.16.2]
config file = None
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/pyenv/versions/ansible-role-amazon-ssm-agent/lib/python3.10/site-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/pyenv/versions/ansible-role-amazon-ssm-agent/bin/ansible
python version = 3.10.9 (main, Apr 23 2024, 15:25:11) [GCC 11.4.0] (/opt/pyenv/versions/ansible-role-amazon-ssm-agent/bin/python3)
jinja version = 3.1.3
libyaml = True
❯ molecule --version
molecule 24.2.1 using python 3.10
ansible:2.16.2
azure:23.5.3 from molecule_plugins
containers:23.5.3 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
default:24.2.1 from molecule
docker:23.5.3 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
ec2:23.5.3 from molecule_plugins
gce:23.5.3 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
openstack:23.5.3 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
podman:23.5.3 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
vagrant:23.5.3 from molecule_plugins
❯ pytest --version
pytest 8.1.1
🐛 Summary
During molecule "verify" phase,
pytest
errors out when attempting to collect the test cases.To reproduce
Steps to reproduce the behavior:
./setup-env
molecule test
or the following commands (in order):Expected behavior
Molecule executes successfully without errors
Any helpful log output or screenshots
Proposed Solution
According to this output,
pytest
isn't configured to set therootdir
, and the default of/
is used instead. Touchingpytest.ini
in the root directory of this repo seems to resolve the issue.