Ansible-test units is failing in github actions now

I’m the author of the pfsensible.core collection. My ansible unit tests are now failing in github actions with:

[gw2] linux -- Python 3.10.16 /opt/hostedtoolcache/Python/3.10.16/x64/bin/python

self = <ansible_collections.pfsensible.core.tests.unit.plugins.modules.test_pfsense_vlan.TestPFSenseVlanModule testMethod=test_vlan_delete_unexistent>

    def test_vlan_delete_unexistent(self):
        """ test deletion of a vlan """
        vlan = dict(vlan_id=1200, interface='vmx1')
>       self.do_module_test(vlan, delete=True, changed=False)

tests/unit/plugins/modules/test_pfsense_vlan.py:122: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/unit/plugins/modules/pfsense_module.py:171: in do_module_test
    result = self.execute_module(changed=changed, failed=failed, msg=msg)
tests/unit/plugins/modules/pfsense_module.py:144: in execute_module
    result = self.changed(changed)
tests/unit/plugins/modules/pfsense_module.py:203: in changed
    self.module.main()
plugins/modules/pfsense_vlan.py:77: in main
    module = AnsibleModule(
/tmp/ansible-test-_yh7xkcf/ansible/module_utils/basic.py:416: in __init__
    self._load_params()
/tmp/ansible-test-_yh7xkcf/ansible/module_utils/basic.py:1214: in _load_params
    self.params = _load_params()
/tmp/ansible-test-_yh7xkcf/ansible/module_utils/basic.py:326: in _load_params
    buffer = sys.stdin.buffer.read()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def read(self, size: int = -1) -> str:
>       raise OSError(
            "pytest: reading from stdin while output is captured!  Consider using `-s`."
        )
E       OSError: pytest: reading from stdin while output is captured!  Consider using `-s`.

/opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/_pytest/capture.py:227: OSError

I’ve tried adding this to setup.cfg:

[tool:pytest]
addopts = -s

to no avail.

See Workflow runs · pfsensible/core · GitHub

Any suggestions would be greatly appreciated.

Check out Making a collection compatible with data tagging - #2 by felixfontein, that’s very likely what makes your test fail.

Really? I’m only testing with core 2.14-2.17. Also, currently using:

from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args

and not mucking with _ANSIBLE_ARGS.

Could this be related to utilizing community.internal_test_tools but not pinning the version to use?

I’ve never used that collection, but maybe a change to ModuleTestCase‎ has caused it. And without pinning the version of that collection, if behavior changed, it could cause your tests to break.

1 Like

It is related to community.internal_test_tools 0.15.0, which has a breaking change, see the changelog: community.internal_test_tools/CHANGELOG.md at main · ansible-collections/community.internal_test_tools · GitHub

Basically CI has been broken for three weeks (since 0.15.0 has been released), but since nothing ran in Workflow runs · pfsensible/core · GitHub since then it was kind of invisible :slight_smile:

1 Like

(0.16.0 should be out soon with DT support, once I figure out why the codecov uploader is suddenly failing…)

(Update: 0.16.0 is out by now.)

Switching to with set_module_args(args): did the trick. Thanks!