Changeset - 33f4baab1260
[Not reviewed]
0 3 0
Branko Majic (branko) - 4 years ago 2020-05-07 22:38:48
branko@majic.rs
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.
3 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
roles/common/molecule/default/tests/test_default.py
Show inline comments
 
@@ -327,13 +327,13 @@ def test_pipreqcheck_virtualenv_packages(host, pip_path, expected_packages):
 
    requirements checks..
 
    """
 

	
 
    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.
 
    if "pkg-resources==0.0.0" in actual_packages:
 
        actual_packages.remove("pkg-resources==0.0.0")
 

	
roles/common/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -43,13 +43,13 @@ def test_ssh_login_mechanisms(host):
 

	
 
    transport = paramiko.transport.Transport(sock)
 
    transport.connect()
 

	
 
    try:
 
        transport.auth_none('')
 
    except paramiko.transport.BadAuthenticationType, err:
 
    except paramiko.transport.BadAuthenticationType as err:
 
        assert err.allowed_types == ['publickey']
 

	
 

	
 
def test_emacs_electric_indent_mode(host):
 
    """
 
    Tests if Emacs electric indent mode has been disabled via custom
roles/common/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -29,13 +29,14 @@ def test_bash_prompt_content(host):
 
    Tests that custom bash prompt has been configured correctly with specified
 
    colour and prompt.
 
    """
 

	
 
    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
 

	
 

	
 
def test_common_installed_packages_common(host):
 
    """
 
    Tests that user-provided common packages have been installed.
 
@@ -59,13 +60,13 @@ def test_ssh_login_mechanisms(host):
 

	
 
    transport = paramiko.transport.Transport(sock)
 
    transport.connect()
 

	
 
    try:
 
        transport.auth_none('')
 
    except paramiko.transport.BadAuthenticationType, err:
 
    except paramiko.transport.BadAuthenticationType as err:
 
        assert err.allowed_types == ['publickey']
 

	
 

	
 
def test_emacs_electric_indent_mode(host):
 
    """
 
    Tests if Emacs electric indent mode has been disabled via custom
0 comments (0 inline, 0 general)