Skip to content

Commit

Permalink
[STYLE] reduced some more complexity in test utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
reactive-firewall committed Jan 21, 2022
1 parent 7d03fef commit b49aee5
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ def checkCovCommand(args=[None]):
args.insert(3, str("--source=multicast"))
return args


def checkStrOrByte(theInput):
theOutput = None
try:
theOutput = theInput
if isinstance(theInput, bytes):
theOutput = theInput.decode("""utf_8""")
except UnicodeDecodeError:
theOutput = bytes(theInput)
return theOutput


def checkPythonCommand(args=[None], stderr=None):
"""function for backend subprocess check_output command"""
theOutput = None
Expand All @@ -228,15 +240,9 @@ def checkPythonCommand(args=[None], stderr=None):
try:
if err.output is not None:
theOutput = err.output
except Exception as cascadeErr:
except Exception:
theOutput = None
cascadeErr = None
del cascadeErr
try:
if isinstance(theOutput, bytes):
theOutput = theOutput.decode("""utf_8""")
except UnicodeDecodeError:
theOutput = bytes(theOutput)
theOutput = checkStrOrByte(theOutput)
return theOutput


Expand Down

0 comments on commit b49aee5

Please sign in to comment.