SUSE-Enceladus / img-proof

img-proof provides a command line utility to test images in the Public Cloud
https://img-proof.readthedocs.io/en/latest/
GNU General Public License v3.0
14 stars 7 forks source link

Include pytest.ini file in tests root dir #389

Closed apozsuse closed 3 months ago

apozsuse commented 3 months ago

I found plenty of issues in pytest(example), but not the exact reason for the change in the behavior in pytest 7.4.X (or python 3.11).

Fixtures used in the tests are defined in the conftest.py file in /usr/share/lib/img_proof/tests, but for some reason pytest is not setting the rootdir to that directory but to /usr/share/lib/img_proof/tests/SLES, and the conftest.py in the parent directory does not get loaded.

Including an empty pytest.ini in the root test directory is enough for the algorithm to find the rootdir to be found properly.

Before the file is present:

metadata: {'Python': '3.11.9', 'Platform': 'Linux-5.14.21-150500.55.65-default-x86_64-with-glibc2.31', 'Packages': {'pytest': '7.4.2', 'pluggy': '1.0.0'}, 'Plugins': {'testinfra': '10.0.0', 'metadata': '3.1.1', 'json-report': '1.5.0'}}
rootdir: /usr/share/lib/img_proof/tests/SLES

After the file is present:

metadata: {'Python': '3.11.9', 'Platform': 'Linux-5.14.21-150500.55.65-default-x86_64-with-glibc2.31', 'Packages': {'pytest': '7.4.2', 'pluggy': '1.0.0'}, 'Plugins': {'testinfra': '10.0.0', 'metadata': '3.1.1', 'json-report': '1.5.0'}}
rootdir: /usr/share/lib/img_proof/tests
rjschwei commented 3 months ago

Since @smarlowucf is away and we need to get the tests working again I am going to merge this.

smarlowucf commented 2 months ago

👍🏼