コード例 #1
0
def make_part_functions():
    return [
        one_part,
        partial(make_parts, get_size=15),
        partial(make_parts, get_size=geometric_series()),
        partial(make_parts, get_size=geometric_series(), dir=-1),
        partial(make_parts, get_size=fancy_series())
    ]
コード例 #2
0
def parametrize_do_parts():
    funcs = [
        one_part,
        partial(make_parts, get_size=15),
        partial(make_parts, get_size=geometric_series()),
        partial(make_parts, get_size=geometric_series(), dir=-1),
        partial(make_parts, get_size=fancy_series())
    ]

    ids = ['one', 'const', 'geom', 'invgeom', 'fancy']

    return pytest.mark.parametrize('do_parts', funcs, ids=ids)
コード例 #3
0
def parametrize_do_parts():
    funcs = [
        one_part,
        partial(make_parts, get_size=15),
        partial(make_parts, get_size=geometric_series()),
        partial(make_parts, get_size=geometric_series(), dir=-1),
        partial(make_parts, get_size=fancy_series())
    ]

    ids = ['one', 'const', 'geom', 'invgeom', 'fancy']

    return pytest.mark.parametrize('do_parts', funcs, ids=ids)
コード例 #4
0
def make_part_functions():
    return [
        one_part,
        partial(make_parts, get_size=15),
        partial(make_parts, get_size=geometric_series()),
        partial(make_parts, get_size=geometric_series(), dir=-1),
        partial(make_parts, get_size=fancy_series())
    ]


@pytest.mark.parametrize('data,get_size,dir,parts',
[
    (b'abcde', 2, 1, [b'ab', b'cd', b'e']),
    (b'abcde', 2, -1, [b'a', b'bc', b'de']),
    (b'aaBBBBccccCCCCd', geometric_series(), 1,
     [b'aa', b'BBBB', b'ccccCCCC', b'd']),
    (b'dCCCCccccBBBBaa', geometric_series(), -1,
     [b'd', b'CCCCcccc', b'BBBB', b'aa'])
])
def test_make_parts(data, get_size, dir, parts):
    assert make_parts(data, get_size, dir) == parts


def parametrize_make_parser():
    ids = []
    factories = []
    if hasattr(parsers, 'make_cext'):
        factories.append(partial(parsers.make_cext, Mock))
        ids.append('cext')
コード例 #5
0
        return parser, protocol


def make_cffi(protocol_factory=CffiTracingProtocol):
    protocol = protocol_factory()
    parser = cffiparser.HttpRequestParser(
        protocol.on_headers, protocol.on_body, protocol.on_error)

    return parser, protocol


@pytest.mark.parametrize('data,get_size,dir,parts', [
    (b'abcde', 2, 1, [b'ab', b'cd', b'e']),
    (b'abcde', 2, -1, [b'a', b'bc', b'de']),
    (b'aaBBBBccccCCCCd', geometric_series(), 1,
     [b'aa', b'BBBB', b'ccccCCCC', b'd']),
    (b'dCCCCccccBBBBaa', geometric_series(), -1,
     [b'd', b'CCCCcccc', b'BBBB', b'aa'])
])
def test_make_parts(data, get_size, dir, parts):
    assert make_parts(data, get_size, dir) == parts


def parametrize_make_parser():
    ids = []
    factories = []
    if 'make_c' in globals():
        factories.append(make_c)
        ids.append('c')