Skip to content

Instantly share code, notes, and snippets.

@KentaYamada
Last active February 14, 2017 03:53
Show Gist options
  • Save KentaYamada/4f024bf43fd1cfaa324e1330519c7cdc to your computer and use it in GitHub Desktop.
Save KentaYamada/4f024bf43fd1cfaa324e1330519c7cdc to your computer and use it in GitHub Desktop.
Unit testデータサンプル
import unittest
from utility import from_json # ラッパー関数があると便利かも
class TestSample(unittest.TestCase):
def test_save_ok(self):
test_case = from_json("test_save_ok")
for d in test_case['data']:
self.assertEqual(test_case['expected'], d)
if __name__ == "__main__":
unittest.main()
{
"test_save_ok": {
"expected": true,
"data": [
]
},
"test_save_ng": {
"expected": true,
"data": [
]
},
"test_validation_ok": {
"expected": true,
"data": [
]
},
"test_validation_ng": {
"expected": false,
"data": [
]
},
"test_find_all_ok": {
"expected": 10,
"data": [
]
},
"test_find_any_ok": {
"expected": "Tom",
"data": [
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment