daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 68 in 5 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import logging
  2. import unittest
  3. import unittest.mock
  4. import io
  5.  
  6. logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
  7.  
  8. class TestSomething(unittest.TestCase):
  9.     @unittest.mock.patch('sys.stdout', new_callable=io.StringIO)
  10.     def assert_stout(self, n, expected_out, mock_stdout):
  11.         print(n)
  12.         self.assertEqual(mock_stdout.getvalue(), expected_out)
  13.        
  14. TestSomething.assert_stout("Hello World", "Hello World")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top