Last active
December 23, 2017 09:04
-
-
Save okusama27/4c9fa7d203a50b3278f210ca7d1dcbb3 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 | |
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() | |
def tearDown(self): | |
print('tearDown') | |
@classmethod | |
def setUpClass(cls): | |
cls.msg = 'setUpClass msg' | |
print('setUpClass') | |
@classmethod | |
def tearDownClass(cls): | |
print('tearDownClass') | |
print(cls.msg) | |
def test_method_1(self): | |
print('test_method_1') | |
expected = 'method_1' | |
actual = self.sample.method_1() | |
self.assertEqual(expected, actual) | |
def test_method_2(self): | |
print('test_method_2') | |
expected = 'method_2' | |
actual = self.sample.method_2() | |
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