Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use py3 instead py2 #3153

Merged
merged 2 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
- docker
language: python
python:
- "2.7"
- "3.6"
install:
- pip install -r requirements.txt

Expand Down
14 changes: 6 additions & 8 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
'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
Expand All @@ -38,9 +38,7 @@ def run_bash(self, command, *args, **kwargs):
return out

funcType = type(Docker.run)
Docker.run = funcType(run_bash,
Docker,
testinfra.backend.docker.DockerBackend)
Docker.run = funcType(run_bash, Docker)
return Docker


Expand Down Expand Up @@ -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}
Expand All @@ -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}\"
Expand Down
4 changes: 2 additions & 2 deletions test/test_000_build_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
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
10 changes: 5 additions & 5 deletions test/test_automated_install.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from textwrap import dedent
import re
from conftest import (
from .conftest import (
SETUPVARS,
tick_box,
info_box,
Expand Down Expand Up @@ -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 <<EOF> /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)
Expand All @@ -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


Expand All @@ -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

Expand All @@ -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


Expand Down
3 changes: 1 addition & 2 deletions test/test_centos_fedora_support.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import pytest
from conftest import (
from .conftest import (
tick_box,
info_box,
cross_box,
mock_command,
mock_command_2,
)


Expand Down
2 changes: 1 addition & 1 deletion test/test_shellcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27
envlist = py36

[testenv]
whitelist_externals = docker
Expand Down