Created
December 24, 2017 13:40
-
-
Save okusama27/62b683559439330ca50d34b01798ff26 to your computer and use it in GitHub Desktop.
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 unittest | |
from unittest.mock import MagicMock | |
class SampleMethod(): | |
def method_1(self): | |
print('method_1') | |
return 'method_1' | |
def method_2(self): | |
print('method_2') | |
return 'method_2' | |
class TestSampleMethod(unittest.TestCase): | |
def setUp(self): | |
print('setUp') | |
self.sample = SampleMethod() | |
self.sample.method_1 = MagicMock(return_value='AAA') | |
def tearDown(self): | |
print('tearDown') | |
def test_method_1(self): | |
print('test_method_1') | |
expected = 'AAA' | |
actual = self.sample.method_1() | |
self.assertEqual(expected, actual) | |
if __name__ == '__main__': | |
# unittestを実行 | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment