示例#1
0
 def test_using_context_manager(self):
     with mock.patch('work.os') as mocked_os:
         work_on()
         mocked_os.getcwd.assert_called_once()
示例#2
0
 def test_using_context_manager(self):
     with mock.patch('work.os.getcwd', return_value='testing') as mocked_os:
         assert work_on() == 'testing'
示例#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'
示例#4
0
 def test_using_decorator(self, mocked_os):
     work_on()
     mocked_os.getcwd.assert_called_once()
示例#5
0
文件: test_work.py 项目: zympz/wtmock
 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'
示例#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'