Created
September 25, 2014 09:50
-
-
Save KentaYamada/458829f77feeef23e7ac to your computer and use it in GitHub Desktop.
Pythonで単体テスト
This file contains hidden or 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
# -*- coding:utf-8 -*- | |
#テストしたい方を実装 | |
def read_file(): | |
with open('test.txt', mode='r') as f: | |
return f.read() |
This file contains hidden or 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
# -*- coding:utf-8 -*- | |
import unittest | |
from sample import read_file | |
#テストケースクラスを継承する | |
class SampleTest(unittest.TestCase): | |
#テスト用メソッド実装 | |
def test_read_file(self): | |
self.assertEqual('test', read_file()) | |
#テストケースクラスを継承したクラス全部テストしてくれるらしい | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment