MCPcopy Index your code
hub / github.com/bleachbit/bleachbit / assert_execute

Function assert_execute

windows/setup.py:143–160  ·  view source on GitHub ↗

Run a command and check it returns the expected output. A timeout guards against hangs (e.g., GTK main loop not quitting). On timeout, the child is killed and any captured output is logged to aid troubleshooting.

(args, expected_output, timeout=120)

Source from the content-addressed store, hash-verified

141
142
143def assert_execute(args, expected_output, timeout=120):
144 """Run a command and check it returns the expected output.
145
146 A timeout guards against hangs (e.g., GTK main loop not quitting).
147 On timeout, the child is killed and any captured output is logged
148 to aid troubleshooting.
149 """
150 try:
151 actual_output = subprocess.check_output(
152 args, stderr=subprocess.STDOUT, timeout=timeout).decode(SetupEncoding)
153 except subprocess.TimeoutExpired as e:
154 partial = (e.output or b'').decode(SetupEncoding, errors='replace')
155 logger.error('Command %s timed out after %ss. Partial output:\n%s',
156 args, timeout, partial)
157 raise RuntimeError(f'Timeout running {args} after {timeout}s') from e
158 if -1 == actual_output.find(expected_output):
159 raise RuntimeError(
160 f'When running command {args} expected output {expected_output} but got {actual_output}')
161
162
163def assert_execute_console():

Callers 1

assert_execute_consoleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected