MCPcopy
hub / github.com/QData/TextAttack / update_test

Function update_test

tests/test_command_line/update_test_outputs.py:13–28  ·  view source on GitHub ↗
(command, outfile, add_magic_str=False)

Source from the content-addressed store, hash-verified

11
12
13def update_test(command, outfile, add_magic_str=False):
14 if isinstance(command, str):
15 print(">", command)
16 else:
17 print("\n".join(f"> {c}" for c in command))
18 result = run_command_and_get_result(command)
19 stdout = result.stdout.decode().strip()
20 if add_magic_str:
21 # add magic string to beginning
22 magic_str = "/.*/"
23 stdout = magic_str + stdout
24 # add magic string after attack
25 mid_attack_str = "\n--------------------------------------------- Result 1"
26 stdout.replace(mid_attack_str, magic_str + mid_attack_str)
27 # write to file
28 open(outfile, "w").write(stdout + "\n")
29
30
31def main():

Callers 1

mainFunction · 0.85

Calls 3

stripMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected