# Path: integration_tests/strategies.py

# 
# Path: misc/client.py
# def readline(sock):
# def readexact(sock, size):
#     def __init__(self, sock):
#     def read_status_line(self):
#     def read_headers(self):
#     def encoding(self):
#     def read_body(self):
#     def json(self):
#     def __init__(self, addr):
#     def maybe_connect(self):
#     def putline(self, line=None):
#     def putclose(self, data):
#     def putrequest(self, method, path, query_string=None):
#     def request(self, method, path, query_string=None, headers=None,
#                 body=None):
#     def putheader(self, name, value):
#     def endheaders(self, body=None):
#     def getresponse(self):
#     def close(self):
# def chunked_encoder(data):
# class Response:
# class Connection:


import pytest
import json
import base64
import integration_tests.common
from functools import partial
from hypothesis import given, settings, Verbosity, HealthCheck
from integration_tests import strategies as st
from misc import client


@pytest.fixture(autouse=True, scope='module')
def server():
    server = integration_tests.common.start_server(
        'integration_tests/dump.py', path='.test')

    yield server

    server.terminate()
    server.wait() == 0


@pytest.fixture(params=['example', 'test'])
def connect(request):
    if request.param == 'example':
        yield partial(client.Connection, 'localhost:8080')
    elif request.param == 'test':
        connection = client.Connection('localhost:8080')
        close = connection.close
        connection.close = lambda: None
        yield lambda: connection
        close()


@pytest.fixture(params=['', '/async'], ids=['sync', 'async'])
def prefix(request):
    return request.param



# Path: integration_tests/strategies.py

# 
# Path: misc/client.py
# def readline(sock):
# def readexact(sock, size):
#     def __init__(self, sock):
#     def read_status_line(self):
#     def read_headers(self):
#     def encoding(self):
#     def read_body(self):
#     def json(self):
#     def __init__(self, addr):
#     def maybe_connect(self):
#     def putline(self, line=None):
#     def putclose(self, data):
#     def putrequest(self, method, path, query_string=None):
#     def request(self, method, path, query_string=None, headers=None,
#                 body=None):
#     def putheader(self, name, value):
#     def endheaders(self, body=None):
#     def getresponse(self):
#     def close(self):
# def chunked_encoder(data):
# class Response:
# class Connection:


# Path: integration_tests/test_request.py
import pytest
import json
import base64
import integration_tests.common
from functools import partial
from hypothesis import given, settings, Verbosity, HealthCheck
from integration_tests import strategies as st
from misc import client



@pytest.fixture(autouse=True, scope='module')
def server():
    server = integration_tests.common.start_server(
        'integration_tests/dump.py', path='.test')

    yield server

    server.terminate()
    server.wait() == 0


@pytest.fixture(params=['example', 'test'])
def connect(request):
    if request.param == 'example':
        yield partial(client.Connection, 'localhost:8080')
    elif request.param == 'test':
        connection = client.Connection('localhost:8080')
        close = connection.close
        connection.close = lambda: None
        yield lambda: connection
        close()


@pytest.fixture(params=['', '/async'], ids=['sync', 'async'])
def prefix(request):
    return request.param



@given(method=st.method)