Skip to content

Pytest stopped working

Description

Since recently, pytest_podman jobs no longer succeeds (example, last working example).

The problem can be reproduced manually with example-playbook:

$ cp -r /path/to/ancible/tests .
$ ANCIBLE_PATH=/path/to/ancible make pytest-local
Test session starts (platform: linux, Python 3.13.5, pytest 8.4.1, pytest-sugar 1.1.1)
ansible: 2.18.8
rootdir: /home/user/file/tor/gitlab/tpo/onion-services/ansible/example-playbook
plugins: sugar-1.1.1, xdist-3.8.0, ansible-25.8.0, plus-0.8.1
collected 1 item / 1 deselected / 0 selected                                                                                                                             


Results (2.41s):
       1 deselected
make: *** [../ancible/Makefile.ancible:38: pytest-local] Error 5

It seems pytest is deselecting the molecule test. Invoking it directly suggests that the test is not selected because a parameter is not being set:

$ PIPENV_PIPFILE=/path/to/ancible/Pipfile pipenv run pytest -r A --collect-only
Test session starts (platform: linux, Python 3.13.5, pytest 8.4.1, pytest-sugar 1.1.1)
ansible: 2.18.8
rootdir: /home/user/file/tor/gitlab/tpo/onion-services/ansible/example-playbook
plugins: sugar-1.1.1, xdist-3.8.0, ansible-25.8.0, plus-0.8.1
collected 1 item                                                                                                                                                         

<Dir example-playbook>
  <Dir tests>
    <Dir integration>
      <Module test_integration.py>
        <Function test_integration[NOTSET]>


Results (1.93s):
$ PIPENV_PIPFILE=/path/to/ancible/Pipfile pipenv run pytest -r A               
Test session starts (platform: linux, Python 3.13.5, pytest 8.4.1, pytest-sugar 1.1.1)
ansible: 2.18.8
rootdir: /home/user/file/tor/gitlab/tpo/onion-services/ansible/example-playbook
plugins: sugar-1.1.1, xdist-3.8.0, ansible-25.8.0, plus-0.8.1
collected 1 item                                                                                                                                                         

 tests/integration/test_integration.py s                                                                                                                   100% ██████████
================================================================================= PASSES =================================================================================
======================================================================== short test summary info =========================================================================
PASSED tests/integration/test_integration.py::test_integration[NOTSET]
SKIPPED [1] tests/integration/test_integration.py: got empty parameter set for (molecule_scenario)

Results (1.99s):
       1 skipped

Things are further complicated because pytest does not allow users to know why a test was deselected.

This may have to do with the recent move to Debian trixie.

Tasks

Time estimation

  • Complexity: small (1 day)
  • Uncertainty: low (x1.1)
  • Reference (adapted)
Edited by Silvio Rhatto