Created
December 24, 2017 14:25
-
-
Save okusama27/906283ebbd39cdeab676ce2be523bece 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 patch | |
from sample_method import SampleMethod | |
class TestSampleMethod(unittest.TestCase): | |
def setUp(self): | |
print('setUp') | |
self.sample = SampleMethod() | |
def tearDown(self): | |
print('tearDown') | |
@patch('sample_method.SampleMethod.method_1') | |
def test_method_1(self, mock_method_1): | |
print('test_method_1') | |
mock_method_1.return_value = 'AAA' | |
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