MCPcopy
hub / github.com/aws/aws-cli / _run_cmd

Function _run_cmd

tests/integration/customizations/test_generatecliskeleton.py:107–129  ·  view source on GitHub ↗
(cmd, capsys, expected_rc=0)

Source from the content-addressed store, hash-verified

105
106
107def _run_cmd(cmd, capsys, expected_rc=0):
108 logging.debug("Calling cmd: %s", cmd)
109 # Drivers do not seem to be reusable since the formatters seem to not clear
110 # themselves between runs. This is fine in practice since a driver is only
111 # called once but for tests it means we need to create a new driver for
112 # each test, which is far more heavyweight than it needs to be. Might be
113 # worth seeing if we can make drivers reusable to speed these up generated
114 # tests.
115 driver = create_clidriver()
116 try:
117 rc = driver.main(cmd.split())
118 except SystemExit as e:
119 # We need to catch SystemExit so that we
120 # can get a proper rc and still present the
121 # stdout/stderr to the test runner so we can
122 # figure out what went wrong.
123 rc = e.code
124 stdout, stderr = capsys.readouterr()
125 assert rc == expected_rc, (
126 f"Unexpected rc (expected: {expected_rc}, actual: {rc}) "
127 f"for command: {cmd}\nstdout:\n{stdout}stderr:\n{stderr}"
128 )
129 return stdout, stderr, rc

Callers 2

test_gen_input_skeletonFunction · 0.85

Calls 2

create_clidriverFunction · 0.90
mainMethod · 0.45

Tested by

no test coverage detected