Skip to content

Commit

Permalink
Merge pull request #1210 from AntelopeIO/test-harness-urllib-configur…
Browse files Browse the repository at this point in the history
…able-limit

Add prettyPrint and printReturnLimit to processUrllibRequest()
  • Loading branch information
jgiszczak authored May 23, 2023
2 parents 2d06cfb + 5d0ee1f commit d215122
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/TestHarness/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def processCleosCmd(self, cmd, cmdDesc, silentErrors=True, exitOnError=False, ex

return trans

def processUrllibRequest(self, resource, command, payload={}, silentErrors=False, exitOnError=False, exitMsg=None, returnType=ReturnType.json, method="POST", endpoint=None):
def processUrllibRequest(self, resource, command, payload={}, silentErrors=False, exitOnError=False, exitMsg=None, returnType=ReturnType.json, method="POST", endpoint=None, prettyPrint=False, printReturnLimit=1024):
if not endpoint:
endpoint = self.endpointHttp
cmd = f"{endpoint}/v1/{resource}/{command}"
Expand Down Expand Up @@ -625,8 +625,10 @@ def processUrllibRequest(self, resource, command, payload={}, silentErrors=False
if Utils.Debug:
end=time.perf_counter()
Utils.Print("cmd Duration: %.3f sec" % (end-start))
printReturn=json.dumps(rtn) if returnType==ReturnType.json else rtn
Utils.Print("cmd returned: %s" % (printReturn[:1024]))
indent = 2 if prettyPrint else None
separators = (', ',': ') if prettyPrint else (',',':')
printReturn=json.dumps(rtn, indent=indent, separators=separators) if returnType==ReturnType.json else rtn
Utils.Print("cmd returned: %s" % (printReturn[:printReturnLimit]))
except urllib.error.HTTPError as ex:
if not silentErrors:
end=time.perf_counter()
Expand Down

0 comments on commit d215122

Please sign in to comment.