Merge pull request #11449 from msabramo/make_test-module_work_in_v2

Make test module work in v2
This commit is contained in:
Brian Coca 2015-07-03 22:58:13 -04:00
commit 9de6471867

View file

@ -35,6 +35,8 @@ import subprocess
import traceback import traceback
import optparse import optparse
import ansible.utils as utils import ansible.utils as utils
from ansible.parsing.utils.jsonify import jsonify
from ansible.parsing.splitter import parse_kv
import ansible.module_common as module_common import ansible.module_common as module_common
import ansible.constants as C import ansible.constants as C
@ -74,8 +76,8 @@ def write_argsfile(argstring, json=False):
argspath = os.path.expanduser("~/.ansible_test_module_arguments") argspath = os.path.expanduser("~/.ansible_test_module_arguments")
argsfile = open(argspath, 'w') argsfile = open(argspath, 'w')
if json: if json:
args = utils.parse_kv(argstring) args = parse_kv(argstring)
argstring = utils.jsonify(args) argstring = jsonify(args)
argsfile.write(argstring) argsfile.write(argstring)
argsfile.close() argsfile.close()
return argspath return argspath
@ -150,7 +152,7 @@ def runtest( modfile, argspath):
print "RAW OUTPUT" print "RAW OUTPUT"
print out print out
print err print err
results = utils.parse_json(out) results = json.loads(out)
except: except:
print "***********************************" print "***********************************"
print "INVALID OUTPUT FORMAT" print "INVALID OUTPUT FORMAT"
@ -160,7 +162,7 @@ def runtest( modfile, argspath):
print "***********************************" print "***********************************"
print "PARSED OUTPUT" print "PARSED OUTPUT"
print utils.jsonify(results,format=True) print jsonify(results,format=True)
def rundebug(debugger, modfile, argspath): def rundebug(debugger, modfile, argspath):
"""Run interactively with console debugger.""" """Run interactively with console debugger."""