Skip to content

Commit

Permalink
Fix printing to use function for py3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcgill298 committed May 11, 2018
1 parent f5fb01e commit 26a2686
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
52 changes: 26 additions & 26 deletions test-templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def compare(list_one, list_two):
module_path='/home/travis/build/networktocode/ntc-templates/ntc-ansible/library/')

results = runner.run()
print results
print(results)
tests = results['contacted']['localhost']['tests']

responses = []
Expand All @@ -49,12 +49,12 @@ def compare(list_one, list_two):

responses.append(results)

# print json.dumps(responses, indent=4)
# print(json.dumps(responses, indent=4))
with_parsed = []
# print json.dumps(responses, indent=4)
# print(json.dumps(responses, indent=4))
for rsp in responses:
# print json.dumps(rsp, indent=4)
# print rsp['contacted']['localhost']['invocation']['module_args']
# print(json.dumps(rsp, indent=4))
# print(rsp['contacted']['localhost']['invocation']['module_args'])
args = rsp['contacted']['localhost']['invocation']['module_args']
split = args.split(' ')
for each in split:
Expand All @@ -69,48 +69,48 @@ def compare(list_one, list_two):
host_list=HOSTS
)
results = runner.run()
# print json.dumps(results, indent=4)
# print(json.dumps(results, indent=4))
try:
results['response'] = rsp['contacted']['localhost']['response']
except KeyError:
print 'FAILED'
print each
print rsp
print('FAILED')
print(each)
print(rsp)
sys.exit(1)

# print rsp.get('response')
# print(rsp.get('response'))
with_parsed.append(results)

# print json.dumps(with_parsed, indent=4)
# print(json.dumps(with_parsed, indent=4))

failed = False

for each in with_parsed:
print '****'
print each
print '****'
print('****')
print(each)
print('****')
text = each['contacted']['localhost']['invocation']['module_args']
command = text.split('/')[-1].split('.')[0]
parsed_sample = each['contacted']['localhost']['ansible_facts']['parsed_sample']
result = each['response']

rc, msg = compare(result, parsed_sample)

print command
print(command)
if rc != 0:
print '----> failed'
print 'msg:'
print msg
print '*' * 100
print 'parsed (from parsed file): '
print parsed_sample
print '*' * 100
print 'result (from ntc_show_command): '
print result
print('----> failed')
print('msg:')
print(msg)
print('*' * 100)
print('parsed (from parsed file): ')
print(parsed_sample)
print('*' * 100)
print('result (from ntc_show_command): ')
print(result)
failed = True
else:
print '----> passed'
print '=' * 50
print('----> passed')
print('=' * 50)

if failed:
sys.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_index_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def test_index_ordering():
check_val, check_msg = check_order(os, prior_os, cmd_len, prior_len, os_choices, used_os, cmd, prior_cmd)
if not check_val:
#assertFalse(check_val, msg=check_msg)
print "Error on line: {}".format(row)
print "Error Message: {}".format(check_msg)
print("Error on line: {}".format(row))
print("Error Message: {}".format(check_msg))
assert check_val != False
if os not in used_os:
used_os.append(os)
Expand Down

0 comments on commit 26a2686

Please sign in to comment.