1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Make test-module work in v2

- `jsonify` moved from `ansible.utils` to `ansible.parsing.utils.jsonify`
- I don't see `ansible.utils.parse_json` anymore so I used `json.loads`.
This commit is contained in:
Marc Abramowitz 2015-07-02 18:16:33 +00:00
parent 468770c894
commit ea6ec3bf2c

View file

@ -35,6 +35,7 @@ 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
import ansible.module_common as module_common import ansible.module_common as module_common
import ansible.constants as C import ansible.constants as C
@ -75,7 +76,7 @@ def write_argsfile(argstring, json=False):
argsfile = open(argspath, 'w') argsfile = open(argspath, 'w')
if json: if json:
args = utils.parse_kv(argstring) args = utils.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 +151,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 +161,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."""