Skip to content

Instantly share code, notes, and snippets.

@Kipngetich33
Forked from mauricioaniche/tud_test_base.py
Created December 10, 2020 06:15
Show Gist options
  • Save Kipngetich33/c0cf8052b7bb4de16e8300672ae10830 to your computer and use it in GitHub Desktop.
Save Kipngetich33/c0cf8052b7bb4de16e8300672ae10830 to your computer and use it in GitHub Desktop.
import builtins
input_values = []
print_values = []
def mock_input(s):
print_values.append(s)
return input_values.pop(0)
def mock_input_output_start():
global input_values, print_values
input_values = []
print_values = []
builtins.input = mock_input
builtins.print = lambda s: print_values.append(s)
def get_display_output():
global print_values
return print_values
def set_keyboard_input(mocked_inputs):
global input_values
mock_input_output_start()
input_values = mocked_inputs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment