pyte icon indicating copy to clipboard operation
pyte copied to clipboard

How to use for testing TUIs?

Open yajo opened this issue 5 years ago • 1 comments

Hi there.

I'd love to see an example on how to use this to test a TUI.

Particularly, my project uses https://github.com/tmbo/questionary to ask questions to the user and print a TUI to choose the answers.

I'd love to be able to emulate user interaction, know the messages he's seeing in the screen, emulate some keypress events, read next question, say next answer, etc.

I've been trying to get my head around how to use pyte for this purpose and I'm pretty sure it's possible, but I can't get to how. I'd like something like this pseudocode:

my_process = ['copier', 'copy', src_path, dst_path]
with some_magic_from_pyte(my_process) as input, screen:
    assert 'do_you_love_me?' in screen.display
    input.send('y')
    assert 'your_name?' in screen.display
    input.send('yajo\r')
    assert my_process_did_what_it_had_to_do()

Any help on how to do something similar please? :pray: :innocent:

yajo avatar Sep 28 '20 13:09 yajo

I have a similar use case. I would love to use this as part of an automated testing/fuzzing setup

AlvinKuruvilla avatar Apr 28 '22 15:04 AlvinKuruvilla