Skip to content

Instantly share code, notes, and snippets.

@mauricioaniche
Created September 24, 2019 13:33
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mauricioaniche/671fb553a81df9e6b29434b7e6e53491 to your computer and use it in GitHub Desktop.
Save mauricioaniche/671fb553a81df9e6b29434b7e6e53491 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
@radroid
Copy link

radroid commented Aug 14, 2020

Thanks for sharing! 😄

@Kipngetich33
Copy link

Thanks for Sharing very useful

@legitaxes
Copy link

Hi Mr Mauricio, it does not seem to work for me at all..
I have followed the video's example and it did not work for me
Did I perhaps do something wrong?
It keeps prompting this error of not being able to run the pytest because of an input
image

@54ny7
Copy link

54ny7 commented Sep 30, 2021

Thanks for sharing!
"tud_test_base" What does mean "tud"?
I made a fork. Do you like?

@pjdw
Copy link

pjdw commented Nov 29, 2022

@54ny7 TUD stands for Delft University of Technology; or in dutch Technische Universiteit Delft

@54ny7
Copy link

54ny7 commented Dec 1, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment