Last active
September 20, 2019 17:46
-
-
Save bonprosoft/0de79f50852091f0022f75e10d29bc13 to your computer and use it in GitHub Desktop.
mock.patch 検証2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hoge | |
from hoge import A | |
def print_value(): | |
instance = A() | |
print(instance.value) | |
def print_value2(): | |
instance = hoge.A() | |
print(instance.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A: | |
value = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 | |
100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest import mock | |
import fuga | |
class B: | |
value = 100 | |
def test(): | |
with mock.patch('hoge.A', B): | |
fuga.print_value() | |
fuga.print_value2() | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment