use subprocess moduel correctly
@@ -5,8 +5,7 @@ import sys
import json
import copy
import argparse
-import shlex
-import subprocess
+from subprocess import check_output
import jsonschema
import requests
@@ -22,9 +21,9 @@ class FixResolver(jsonschema.RefResolver):
def jq_check(assertion, data):
- output = subprocess.Popen(shlex.split('echo \'{}\' | jq "{}"'.format(
- json.dumps(data), assertion)))
- return output.strip() == 'true'
+ output = check_output('echo \'{}\' | jq "{}"'.format(
+ json.dumps(data), assertion), shell=True)
+ return output.strip() == b'true'
class TestRunner(object):
@@ -106,6 +105,7 @@ class TestRunner(object):
'expectedResponse': expected_response
}
for assertion in test_case['asserts']:
+ print("Assertion = {}".format(assertion))
assertion_result = jq_check(assertion['program'], assert_data)
print(" - [Assertion]: {} => {}".format(
assertion['description'], assertion_result))
