MCPcopy Index your code
hub / github.com/CITGuru/PyInquirer / feed_app_with_input

Function feed_app_with_input

tests/helpers.py:56–82  ·  view source on GitHub ↗

Create a CommandLineInterface, feed it with the given user input and return the CLI object. This returns a (result, CLI) tuple. note: this only works if you import your prompt and then this function!!

(type, message, text, **kwargs)

Source from the content-addressed store, hash-verified

54
55
56def feed_app_with_input(type, message, text, **kwargs):
57 """
58 Create a CommandLineInterface, feed it with the given user input and return
59 the CLI object.
60
61 This returns a (result, CLI) tuple.
62 note: this only works if you import your prompt and then this function!!
63 """
64 # If the given text doesn't end with a newline, the interface won't finish.
65 assert text.endswith('\n')
66
67 application = getattr(prompts, type).question(message, **kwargs)
68
69 loop = PosixEventLoop()
70 try:
71 inp = PipeInput()
72 inp.send_text(text)
73 cli = CommandLineInterface(
74 application=application,
75 eventloop=loop,
76 input=inp,
77 output=DummyOutput())
78 result = cli.run()
79 return result, cli
80 finally:
81 loop.close()
82 inp.close()
83
84
85def remove_ansi_escape_sequences(text):

Callers 5

test_select_first_choiceFunction · 0.85
test_select_third_choiceFunction · 0.85
test_cycle_backwardsFunction · 0.85

Calls

no outgoing calls

Tested by 5

test_select_first_choiceFunction · 0.68
test_select_third_choiceFunction · 0.68
test_cycle_backwardsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…