-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_app.py
31 lines (25 loc) · 933 Bytes
/
test_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import unittest
import app
class TestHello(unittest.TestCase):
def setUp(self):
app.app.testing = True
self.app = app.app.test_client()
def test_hello(self):
rv = self.app.get('/')
self.assertEqual(rv.status, '200 OK')
self.assertEqual(rv.data, b'Hello World!\n')
def test_hello_hello(self):
rv = self.app.get('/hello/')
self.assertEqual(rv.status, '200 OK')
self.assertEqual(rv.data, b'Hello World!\n')
def test_hello_name(self):
name = 'Simon'
rv = self.app.get(f'/hello/{name}')
self.assertEqual(rv.status, '200 OK')
self.assertIn(bytearray(f"{name}", 'utf-8'), rv.data)
if __name__ == '__main__':
############# Add these lines #############
import xmlrunner
runner = xmlrunner.XMLTestRunner(output='test-reports')
unittest.main(testRunner=runner)
###########################################