1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 06:48:07 +00:00

use py3 instead py2 (#3153)

* use py3 instead py2

Signed-off-by: jnozsc <jnozsc@gmail.com>

* use python 3.6

Signed-off-by: jnozsc <jnozsc@gmail.com>
This commit is contained in:
jnozsc 2020-03-02 23:30:44 -08:00 committed by GitHub
parent 027b97cbfa
commit 4a711340ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 20 deletions

View File

@ -3,7 +3,7 @@ services:
- docker
language: python
python:
- "2.7"
- "3.6"
install:
- pip install -r requirements.txt

View File

@ -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}\"

View File

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

View File

@ -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 <<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)
@ -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

View File

@ -1,10 +1,9 @@
import pytest
from conftest import (
from .conftest import (
tick_box,
info_box,
cross_box,
mock_command,
mock_command_2,
)

View File

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

View File

@ -1,5 +1,5 @@
[tox]
envlist = py27
envlist = py36
[testenv]
whitelist_externals = docker