Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __exit__(self, *args):
self.output = safe_decode(self._output.getvalue())
del self._output
sys.stdout = self._stdout
def test_safe_decode():
assert safe_decode(b"foobar") == "foobar"
assert safe_decode( "foobar") == "foobar"
assert safe_decode(123456789) == 123456789
def assert_stdout(capfd, output):
stdout, _ = capfd.readouterr()
assert safe_decode(output) == safe_decode(stdout)
def test_safe_decode():
assert safe_decode(b"foobar") == "foobar"
assert safe_decode( "foobar") == "foobar"
assert safe_decode(123456789) == 123456789
def test_safe_decode():
assert safe_decode(b"foobar") == "foobar"
assert safe_decode( "foobar") == "foobar"
assert safe_decode(123456789) == 123456789
)
code = proc.wait()
if code and raise_err:
raise PopenError(code, command)
if output:
output, error = proc.communicate()
if output:
output = safe_decode(output)
output = strip(output)
if error:
error = safe_decode(error)
error = strip(error)
if quiet:
return code
else:
return code, output, error
else:
return code
stderr = sp.PIPE if output else None,
env = environ,
cwd = directory,
shell = shell
)
code = proc.wait()
if code and raise_err:
raise PopenError(code, command)
if output:
output, error = proc.communicate()
if output:
output = safe_decode(output)
output = strip(output)
if error:
error = safe_decode(error)
error = strip(error)
if quiet:
return code
else:
return code, output, error
else:
return code