Fixing template integration test for python 2.6 versions

No longer immediately fallback to to_json if simplejson is not installed
This commit is contained in:
James Cammarata 2015-12-16 18:21:47 -05:00
parent d2c43c421f
commit 407d76b8d5
2 changed files with 3 additions and 6 deletions

View file

@ -100,9 +100,11 @@ def to_nice_json(a, *args, **kw):
else:
if major >= 2:
return simplejson.dumps(a, indent=4, sort_keys=True, *args, **kw)
try:
return json.dumps(a, indent=4, sort_keys=True, cls=AnsibleJSONEncoder, *args, **kw)
except:
# Fallback to the to_json filter
return to_json(a, *args, **kw)
return json.dumps(a, indent=4, sort_keys=True, cls=AnsibleJSONEncoder, *args, **kw)
def bool(a):
''' return a bool for the arg '''

View file

@ -48,11 +48,6 @@
- name: copy known good into place
copy: src=foo.txt dest={{output_dir}}/foo.txt
when: pyver.stdout != '2.6'
- name: copy known good into place
copy: src=foo-py26.txt dest={{output_dir}}/foo.txt
when: pyver.stdout == '2.6'
- name: compare templated file to known good
shell: diff {{output_dir}}/foo.templated {{output_dir}}/foo.txt