I have a main function. In itself, it takes 3 arguments - age, gender, source_of_income.
These arguments are passed via input() to the function.
I want to create a test for it via py test and replace the incoming data:
from unittest.mock import patch
def expected_values():
for item in [2,"F","собственный бизнес"]:
yield item
exp_gen = expected_values()
@patch('builtins.input', lambda *args: next(exp_gen))
def test_main():
assert main.main(age=-2,gender="F",source_of_income="собственный бизнес")
but still the test - does not work
raise IOError("reading from stdin while output is captured")
OSError: reading from stdin while output is captured
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire