@@ -440,15 +440,15 @@ When patches and imports are both used in a test case, the patch only applies to
440440the specific context in which it is called, and does not override the import
441441used elsewhere in the test file. In the following example:
442442
443- - You import ` dangerous_sideffects ` from src .lib, then patch
444- ` src .lib.dangerous_sideffects` . If your source code calls
443+ - You import ` dangerous_sideffects ` from project .lib, then patch
444+ ` project .lib.dangerous_sideffects` . If your source code calls
445445 ` dangerous_sideffects ` (when you run ` say_hello ` ) it will use the Mock
446446 provided by the patch. But if your test case calls ` dangerous_sideffects ` , it
447447 will not use the Mock, and instead will execute the function
448448- The behavior is the same when using stdlib.mock.patch, and pytest-mocker
449449
450450``` python
451- # src .lib
451+ # project .lib
452452def dangerous_sideffects ():
453453 raise RuntimeError (" BOOM" )
454454
@@ -459,12 +459,12 @@ def say_hello():
459459```
460460
461461``` python
462- from src .lib import say_hello, dangerous_sideffects
462+ from project .lib import say_hello, dangerous_sideffects
463463
464464
465465def test_pytest (mocker ):
466466 # Given this context
467- mock_dangerous_sideffects = mocker.patch(" src .lib.dangerous_sideffects" )
467+ mock_dangerous_sideffects = mocker.patch(" project .lib.dangerous_sideffects" )
468468 # When we run the code
469469 ret = say_hello()
470470 # Then we expect the result
0 commit comments