From 33f4baab1260b120bd2e791cbc88b811614c2239 2020-05-07 22:38:48 From: Branko Majic Date: 2020-05-07 22:38:48 Subject: [PATCH] MAR-149: Minor syntax fixes for Python 3 in tests for common role: - Do not use the unicode function (this still might break, need to test it). - Fix syntax used for catching exceptions within variables. - Fix one small linting error related to row length. --- diff --git a/roles/common/molecule/default/tests/test_default.py b/roles/common/molecule/default/tests/test_default.py index acaa5a0d43af09fb57035b7b62de26b49551e5b1..f481064435a30e5e108a7b45684b6ad21140320b 100644 --- a/roles/common/molecule/default/tests/test_default.py +++ b/roles/common/molecule/default/tests/test_default.py @@ -330,7 +330,7 @@ def test_pipreqcheck_virtualenv_packages(host, pip_path, expected_packages): packages = host.run("sudo -u %s %s freeze --all" % ('pipreqcheck', pip_path)) # Normalise package names and order. - expected_packages = sorted([unicode(p.lower()) for p in expected_packages]) + expected_packages = sorted([p.lower() for p in expected_packages]) actual_packages = sorted(packages.stdout.lower().strip().split("\n")) # This is a dummy distro-provided package ignored by the pip-tools. diff --git a/roles/common/molecule/default/tests/test_parameters_mandatory.py b/roles/common/molecule/default/tests/test_parameters_mandatory.py index 6379f00f509a5a4c0c1c7dbeb04be77c2728dff1..f115220caffee25323e7d523967874a272787a3e 100644 --- a/roles/common/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/common/molecule/default/tests/test_parameters_mandatory.py @@ -46,7 +46,7 @@ def test_ssh_login_mechanisms(host): try: transport.auth_none('') - except paramiko.transport.BadAuthenticationType, err: + except paramiko.transport.BadAuthenticationType as err: assert err.allowed_types == ['publickey'] diff --git a/roles/common/molecule/default/tests/test_parameters_optional.py b/roles/common/molecule/default/tests/test_parameters_optional.py index 985cf012cc2be17825917301f23a723ec1846476..5eb4fe0073f499fb71a717e631ec2c38612cf03f 100644 --- a/roles/common/molecule/default/tests/test_parameters_optional.py +++ b/roles/common/molecule/default/tests/test_parameters_optional.py @@ -32,7 +32,8 @@ def test_bash_prompt_content(host): config = host.file('/etc/profile.d/bash_prompt.sh') - assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[0;36m\\]\\u@\\h[test]:\\w\\$ \\[\\033[0m\\]'" in config.content_string + assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[0;36m\\]\\u@\\h[test]:\\w\\$ \\[\\033[0m\\]'" in \ + config.content_string assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\u@\\h[test]:\\w\\$ '" in config.content_string @@ -62,7 +63,7 @@ def test_ssh_login_mechanisms(host): try: transport.auth_none('') - except paramiko.transport.BadAuthenticationType, err: + except paramiko.transport.BadAuthenticationType as err: assert err.allowed_types == ['publickey']