summaryrefslogtreecommitdiff
path: root/hacking
diff options
context:
space:
mode:
authorSloane Hertel <shertel@redhat.com>2017-07-11 16:21:51 -0400
committerToshio Kuratomi <a.badger@gmail.com>2017-07-11 13:21:51 -0700
commit113f92548af549cae71f9820539ab241cfdc2d80 (patch)
treef4e561a6d82d288d5a12d5d66c7bcfadb92096dc /hacking
parent292f109ad6fded33dd447493a58768732c2f03e7 (diff)
downloadansible-113f92548af549cae71f9820539ab241cfdc2d80.tar.gz
hacking/test-module: fix for python3 (#26194)
* make hacking/test-module compatible with python3
Diffstat (limited to 'hacking')
-rwxr-xr-xhacking/test-module5
1 files changed, 4 insertions, 1 deletions
diff --git a/hacking/test-module b/hacking/test-module
index bc18420183..89413c8b4b 100755
--- a/hacking/test-module
+++ b/hacking/test-module
@@ -42,6 +42,7 @@ from ansible.parsing.utils.jsonify import jsonify
from ansible.parsing.splitter import parse_kv
import ansible.executor.module_common as module_common
import ansible.constants as C
+from ansible.module_utils._text import to_text
try:
import json
@@ -159,7 +160,7 @@ def boilerplate_module(modfile, args, interpreters, check, destfile):
print("* including generated source, if any, saving to: %s" % modfile2_path)
if module_style not in ('ansiballz', 'old'):
print("* this may offset any line numbers in tracebacks/debuggers!")
- modfile2 = open(modfile2_path, 'w')
+ modfile2 = open(modfile2_path, 'wb')
modfile2.write(module_data)
modfile2.close()
modfile = modfile2_path
@@ -178,6 +179,7 @@ def ansiballz_setup(modfile, modname, interpreters):
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
+ out, err = to_text(out, errors='surrogate_or_strict'), to_text(err)
lines = out.splitlines()
if len(lines) != 2 or 'Module expanded into' not in lines[0]:
print("*" * 35)
@@ -209,6 +211,7 @@ def runtest(modfile, argspath, modname, module_style, interpreters):
cmd = subprocess.Popen(invoke, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = cmd.communicate()
+ out, err = to_text(out), to_text(err)
try:
print("*" * 35)