Skip to content

Instantly share code, notes, and snippets.

@dunossauro
Created January 12, 2018 03:15
Show Gist options
  • Save dunossauro/eb1f3aa236b8b3b140eefee96b3fded4 to your computer and use it in GitHub Desktop.
Save dunossauro/eb1f3aa236b8b3b140eefee96b3fded4 to your computer and use it in GitHub Desktop.
Rapidinha de Python #5
"""
Gist para rapidinha #5: https://youtu.be/95_tm5jh5Gc
"""
from io import StringIO
from unittest import main, TestCase
from unittest.mock import patch
def stdout(string):
print(string)
class Test_stdout(TestCase):
def test_stdout(self):
resultado_esperado = 'Rapidinha de Python\n'
with patch('sys.stdout', new=StringIO()) as fake_out:
stdout('Rapidinha de Python')
self.assertEqual(fake_out.getvalue(), resultado_esperado)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment