20 lines
459 B
Python
20 lines
459 B
Python
import unittest
|
|
import requests
|
|
|
|
|
|
class MyTestCase(unittest.TestCase):
|
|
# def test_something(self):
|
|
# self.assertEqual(True, False)
|
|
|
|
def test_api_index(self):
|
|
res = {"msg": "This is Index Page"}
|
|
r = requests.get("http://localhost:8000/test/")
|
|
if r.status_code == 200:
|
|
self.assertEqual(r.json(), res)
|
|
else:
|
|
self.assertFalse("测试失败")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|