-
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Is it possible to use Mockito to replace sys.argv or sys.stdout?
I could do it with unittest.mock.patch but I'd rather use a single mocking tool:
def it_outputs_answers_based_on_an_argument(when):
with patch('sys.argv', ['cli.py', 'all']):
when('app.cli.ApiClient').search_answers('all').thenReturn([
{
'id': 1,
'question': 'A?',
'content': 'B'
}
])
with patch('sys.stdout', StringIO()) as stdout:
main()
output = stdout.getvalue().strip()
expect(output).to(equal('A?\n--\nB'))kaste and tristancalderbank
Metadata
Metadata
Assignees
Labels
No labels