From 4a711340ef203221e18e31eb05c16aa89512eb60 Mon Sep 17 00:00:00 2001 From: jnozsc Date: Mon, 2 Mar 2020 23:30:44 -0800 Subject: [PATCH] use py3 instead py2 (#3153) * use py3 instead py2 Signed-off-by: jnozsc * use python 3.6 Signed-off-by: jnozsc --- .travis.yml | 2 +- test/conftest.py | 14 ++++++-------- test/test_000_build_containers.py | 4 ++-- test/test_automated_install.py | 10 +++++----- test/test_centos_fedora_support.py | 3 +-- test/test_shellcheck.py | 2 +- tox.ini | 2 +- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa525e01..274c28cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ services: - docker language: python python: - - "2.7" + - "3.6" install: - pip install -r requirements.txt diff --git a/test/conftest.py b/test/conftest.py index 58530d38..5b8be41e 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -14,9 +14,9 @@ SETUPVARS = { 'PIHOLE_DNS_2': '4.2.2.2' } -tick_box = "[\x1b[1;32m\xe2\x9c\x93\x1b[0m]".decode("utf-8") -cross_box = "[\x1b[1;31m\xe2\x9c\x97\x1b[0m]".decode("utf-8") -info_box = "[i]".decode("utf-8") +tick_box = "[\x1b[1;32m\u2713\x1b[0m]" +cross_box = "[\x1b[1;31m\u2717\x1b[0m]" +info_box = "[i]" @pytest.fixture @@ -38,9 +38,7 @@ def Pihole(Docker): return out funcType = type(Docker.run) - Docker.run = funcType(run_bash, - Docker, - testinfra.backend.docker.DockerBackend) + Docker.run = funcType(run_bash, Docker) return Docker @@ -106,7 +104,7 @@ def mock_command(script, args, container): #!/bin/bash -e echo "\$0 \$@" >> /var/log/{script} case "\$1" in'''.format(script=script)) - for k, v in args.iteritems(): + for k, v in args.items(): case = dedent(''' {arg}) echo {res} @@ -133,7 +131,7 @@ def mock_command_2(script, args, container): #!/bin/bash -e echo "\$0 \$@" >> /var/log/{script} case "\$1 \$2" in'''.format(script=script)) - for k, v in args.iteritems(): + for k, v in args.items(): case = dedent(''' \"{arg}\") echo \"{res}\" diff --git a/test/test_000_build_containers.py b/test/test_000_build_containers.py index e9e9e7db..bca67989 100644 --- a/test/test_000_build_containers.py +++ b/test/test_000_build_containers.py @@ -18,6 +18,6 @@ run_local = testinfra.get_backend( def test_build_pihole_image(image, tag): build_cmd = run_local('docker build -f {} -t {} .'.format(image, tag)) if build_cmd.rc != 0: - print build_cmd.stdout - print build_cmd.stderr + print(build_cmd.stdout) + print(build_cmd.stderr) assert build_cmd.rc == 0 diff --git a/test/test_automated_install.py b/test/test_automated_install.py index 567ea241..4e9a7eef 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -1,6 +1,6 @@ from textwrap import dedent import re -from conftest import ( +from .conftest import ( SETUPVARS, tick_box, info_box, @@ -34,7 +34,7 @@ def test_setupVars_are_sourced_to_global_scope(Pihole): This confirms the sourced variables are in scope between functions ''' setup_var_file = 'cat < /etc/pihole/setupVars.conf\n' - for k, v in SETUPVARS.iteritems(): + for k, v in SETUPVARS.items(): setup_var_file += "{}={}\n".format(k, v) setup_var_file += "EOF\n" Pihole.run(setup_var_file) @@ -59,7 +59,7 @@ def test_setupVars_are_sourced_to_global_scope(Pihole): output = run_script(Pihole, script).stdout - for k, v in SETUPVARS.iteritems(): + for k, v in SETUPVARS.items(): assert "{}={}".format(k, v) in output @@ -69,7 +69,7 @@ def test_setupVars_saved_to_file(Pihole): ''' # dedent works better with this and padding matching script below set_setup_vars = '\n' - for k, v in SETUPVARS.iteritems(): + for k, v in SETUPVARS.items(): set_setup_vars += " {}={}\n".format(k, v) Pihole.run(set_setup_vars).stdout @@ -88,7 +88,7 @@ def test_setupVars_saved_to_file(Pihole): output = run_script(Pihole, script).stdout - for k, v in SETUPVARS.iteritems(): + for k, v in SETUPVARS.items(): assert "{}={}".format(k, v) in output diff --git a/test/test_centos_fedora_support.py b/test/test_centos_fedora_support.py index aee16212..4b405920 100644 --- a/test/test_centos_fedora_support.py +++ b/test/test_centos_fedora_support.py @@ -1,10 +1,9 @@ import pytest -from conftest import ( +from .conftest import ( tick_box, info_box, cross_box, mock_command, - mock_command_2, ) diff --git a/test/test_shellcheck.py b/test/test_shellcheck.py index 43e8ad6f..919ad2b9 100644 --- a/test/test_shellcheck.py +++ b/test/test_shellcheck.py @@ -14,5 +14,5 @@ def test_scripts_pass_shellcheck(): "shellcheck -x \"$file\" -e SC1090,SC1091; " "done;") results = run_local(shellcheck) - print results.stdout + print(results.stdout) assert '' == results.stdout diff --git a/tox.ini b/tox.ini index e7916e04..249575b6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27 +envlist = py36 [testenv] whitelist_externals = docker