Created
August 18, 2020 14:52
-
-
Save vlad-bezden/65d3c199c736641387e2fd0dd2f1ef3f to your computer and use it in GitHub Desktop.
Mocking Python print() in Unit Tests
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
from unittest.mock import patch | |
def greet(): | |
print("Hello World") | |
@patch("builtins.print") | |
def test_greet(mock_print): | |
greet() | |
mock_print.assert_called_with("Hello World!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment