Example #1
0
 def test_using_context_manager(self):
     with mock.patch('work.os') as mocked_os:
         work_on()
         mocked_os.getcwd.assert_called_once()
Example #2
0
 def test_using_context_manager(self):
     with mock.patch('work.os.getcwd', return_value='testing') as mocked_os:
         assert work_on() == 'testing'
Example #3
0
 def test_using_return_value(self):
     with mock.patch('work.os.getcwd',
                     return_value='patch_testing') as whatever:
         assert work_on() == 'patch_testing'
Example #4
0
 def test_using_decorator(self, mocked_os):
     work_on()
     mocked_os.getcwd.assert_called_once()
Example #5
0
 def test_using_return_value(self):
     """Note 'as' in the context manager is optional"""
     with mock.patch('work.os.getcwd', return_value='testing'):
         assert work_on() == 'testing'
Example #6
0
 def test_patch_context(self):
     with patch('work.os.getcwd', return_value='testing'):
         self.assertEqual(work_on(), 'testing')
def test_using_return_value():
    with mock.patch('work.os.getcwd', return_value='testing'):
        assert work_on() == 'testing'