This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def test_user_input(monkeypatch): | |
inputs = [10, 'y'] | |
input_generator = (i for i in inputs) | |
monkeypatch.setattr('__builtin__.raw_input', lambda prompt: next(input_generator)) | |
assert raw_input('how many?') == 10 | |
assert raw_input('you sure?') == 'y' |