示例#1
0
 def test_right_way(self):
     # If you want to patch a function imported in some module,
     # you should use a name of module that the function imported in 
     # insteand of the original function's module name.
     with patch('module_a.a.func_b', self._mock_func):
         self.assertEqual(func_a(), 'mocked function')
示例#2
0
from module_a import func_a

func_a()
示例#3
0
 def test_wrong_way(self):
     with patch('module_b.b.func_b', self._mock_func):
         self.assertEqual(func_a(), 'function b')
示例#4
0
def func_b2():
    a = module_a.func_a()
    ...
示例#5
0
 def test_right_way(self):
     # If you want to patch a function imported in some module,
     # you should use a name of module that the function imported in
     # insteand of the original function's module name.
     with patch('module_a.a.func_b', self._mock_func):
         self.assertEqual(func_a(), 'mocked function')
示例#6
0
 def test_wrong_way(self):
     with patch('module_b.b.func_b', self._mock_func):
         self.assertEqual(func_a(), 'function b')
示例#7
0
def func_b2():
    a = func_a()
    ...