def test_msg():
    with server(success_response):
        connection = HTTPConnection(*listener)
        connection.request("GET", "/")
        response = connection.getresponse()
        assert response.msg['Set-Cookie'] == "foo=bar, baz=bar"
        assert response.msg['Content-Type'] == "text/plain"
def test_msg():
    with server(success_response):
        connection = HTTPConnection(*listener)
        connection.request("GET", "/")
        response = connection.getresponse()

        assert response.msg['Set-Cookie'] == "foo=bar, baz=bar"
        assert response.msg['Content-Type'] == "text/plain"
def test_success_response():
    with server(success_response):
        connection = HTTPConnection(*listener)
        connection.request("GET", "/")
        response = connection.getresponse()
        assert response.should_keep_alive()
        assert response.message_complete
        assert not response.should_close()
        assert response.read().decode() == 'Hello World!'
        assert response.content_length == 12
def test_success_response():
    with server(success_response):
        connection = HTTPConnection(*listener)
        connection.request("GET", "/")
        response = connection.getresponse()
        assert response.should_keep_alive()
        assert response.message_complete
        assert not response.should_close()
        assert response.read().decode() == 'Hello World!'
        assert response.content_length == 12
def test_httplib_exception():
    with server(wrong_response_status_line):
        connection = HTTPConnection(*listener)
        connection.request("GET", '/')
        with pytest.raises(HTTPException):
            connection.getresponse()
def test_httplib_exception():
    with server(wrong_response_status_line):
        connection = HTTPConnection(*listener)
        connection.request("GET", '/')
        with pytest.raises(HTTPException):
            connection.getresponse()