about summary refs log tree commit diff
path: root/test/python/test_hello_world.py
blob: 989fc85addcf1d4a423081d7a745933d0d515bd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Mirrors tests/hello_world.rs."""

import http.client
import unittest

from server_test_case import HOST, PORT, ServerTestCase


class HelloWorldTest(ServerTestCase):
    def test_hello_world_returns_ok_with_greeting(self):
        conn = http.client.HTTPConnection(HOST, int(PORT), timeout=5)
        try:
            conn.request("GET", "/")
            response = conn.getresponse()
            body = response.read()
        finally:
            conn.close()
        self.assertEqual(response.status, 200)
        self.assertEqual(body, b"Hello, world!")


if __name__ == "__main__":
    unittest.main()