mirror of https://github.com/ansible/ansible.git
ansible-test - Support pylint assertion rewriting (#80020)
Add support for `pylint` assertion rewriting when running unit tests on Python 3.5 and later.pull/80055/head
parent
2f8f7fba4c
commit
fe2732b91e
@ -0,0 +1,5 @@
|
||||
bugfixes:
|
||||
- ansible-test - Add support for ``pylint`` assertion rewriting when running unit tests on Python 3.5 and later.
|
||||
Resolves issue https://github.com/ansible/ansible/issues/68032
|
||||
known_issues:
|
||||
- ansible-test - Unit tests for collections do not support ``pylint`` assertion rewriting on Python 2.7.
|
@ -0,0 +1,4 @@
|
||||
shippable/generic/group1 # runs in the default test container
|
||||
context/controller
|
||||
needs/target/collection
|
||||
needs/target/ansible-test
|
@ -0,0 +1,6 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
def test_assertion():
|
||||
assert dict(yes=True) == dict(no=False)
|
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ../collection/setup.sh
|
||||
|
||||
set -x
|
||||
|
||||
options=$("${TEST_DIR}"/../ansible-test/venv-pythons.py --only-versions)
|
||||
IFS=', ' read -r -a pythons <<< "${options}"
|
||||
|
||||
for python in "${pythons[@]}"; do
|
||||
if ansible-test units --color --truncate 0 --python "${python}" --requirements "${@}" 2>&1 | tee pylint.log; then
|
||||
echo "Test did not fail as expected."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${python}" = "2.7" ]; then
|
||||
grep "^E *AssertionError$" pylint.log
|
||||
else
|
||||
|
||||
grep "^E *AssertionError: assert {'yes': True} == {'no': False}$" pylint.log
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue