Ejemplo n.º 1
0
def test_partition_target_concurrency_wont_make_tiny_partitions():
    ret = xargs.partition(
        ('foo',), ('A',) * 10,
        4,
        _max_length=50,
    )
    assert ret == (
        ('foo',) + ('A',) * 4,
        ('foo',) + ('A',) * 4,
        ('foo',) + ('A',) * 2,
    )
Ejemplo n.º 2
0
def test_partition_target_concurrency_wont_make_tiny_partitions():
    ret = xargs.partition(
        ('foo',), ('A',) * 10,
        4,
        _max_length=50,
    )
    assert ret == (
        ('foo',) + ('A',) * 4,
        ('foo',) + ('A',) * 4,
        ('foo',) + ('A',) * 2,
    )
Ejemplo n.º 3
0
def test_partition_target_concurrency():
    ret = xargs.partition(
        ('foo',), ('A',) * 22,
        4,
        _max_length=50,
    )
    assert ret == (
        ('foo',) + ('A',) * 6,
        ('foo',) + ('A',) * 6,
        ('foo',) + ('A',) * 6,
        ('foo',) + ('A',) * 4,
    )
Ejemplo n.º 4
0
def test_partition_target_concurrency():
    ret = xargs.partition(
        ('foo',), ('A',) * 22,
        4,
        _max_length=50,
    )
    assert ret == (
        ('foo',) + ('A',) * 6,
        ('foo',) + ('A',) * 6,
        ('foo',) + ('A',) * 6,
        ('foo',) + ('A',) * 4,
    )
Ejemplo n.º 5
0
def test_partition_limits():
    ret = xargs.partition(
        ('ninechars',), (
            # Just match the end (with spaces)
            '.' * 5, '.' * 4,
            # Just match the end (single arg)
            '.' * 10,
            # Goes over the end
            '.' * 5,
            '.' * 6,
        ),
        _max_length=20,
    )
    assert ret == (
        ('ninechars', '.' * 5, '.' * 4),
        ('ninechars', '.' * 10),
        ('ninechars', '.' * 5),
        ('ninechars', '.' * 6),
    )
Ejemplo n.º 6
0
def test_argument_too_long_with_large_unicode(linux_mock):
    cmd = ('ninechars', )
    varargs = ('😑' * 10, )  # 4 bytes * 10
    with pytest.raises(xargs.ArgumentTooLongError):
        xargs.partition(cmd, varargs, 1, _max_length=20)
Ejemplo n.º 7
0
def test_partition_limit_linux(linux_mock):
    cmd = ('ninechars', )
    varargs = ('😑' * 5, )
    ret = xargs.partition(cmd, varargs, 1, _max_length=31)
    assert ret == (cmd + varargs, )
Ejemplo n.º 8
0
def test_partition_limit_win32_py2(win32_py2_mock):
    cmd = ('ninechars', )
    varargs = ('😑' * 5, )  # 4 bytes * 5
    ret = xargs.partition(cmd, varargs, 1, _max_length=31)
    assert ret == (cmd + varargs, )
Ejemplo n.º 9
0
def test_partition_simple():
    assert xargs.partition(('cmd', ), ('foo', ), 1) == (('cmd', 'foo'), )
Ejemplo n.º 10
0
def test_partition_simple():
    assert xargs.partition(('cmd',), ('foo',)) == (('cmd', 'foo'),)
Ejemplo n.º 11
0
def test_partition_limit_linux(linux_mock):
    cmd = ('ninechars',)
    varargs = ('😑' * 5,)
    ret = xargs.partition(cmd, varargs, 1, _max_length=31)
    assert ret == (cmd + varargs,)
Ejemplo n.º 12
0
def test_partition_limit_win32_py2(win32_py2_mock):
    cmd = ('ninechars',)
    varargs = ('😑' * 5,)  # 4 bytes * 5
    ret = xargs.partition(cmd, varargs, 1, _max_length=31)
    assert ret == (cmd + varargs,)
Ejemplo n.º 13
0
def test_partition_limit_win32_py3(win32_py3_mock):
    cmd = ('ninechars',)
    # counted as half because of utf-16 encode
    varargs = ('😑' * 5,)
    ret = xargs.partition(cmd, varargs, 1, _max_length=21)
    assert ret == (cmd + varargs,)
Ejemplo n.º 14
0
def test_argument_too_long():
    with pytest.raises(xargs.ArgumentTooLongError):
        xargs.partition(('a' * 5, ), ('a' * 5, ), 1, _max_length=10)
Ejemplo n.º 15
0
def test_argument_too_long():
    with pytest.raises(xargs.ArgumentTooLongError):
        xargs.partition(('a' * 5,), ('a' * 5,), _max_length=10)
Ejemplo n.º 16
0
def test_partition_trivial():
    assert xargs.partition(('cmd', ), (), 1) == (('cmd', ), )
Ejemplo n.º 17
0
def test_partition_trivial():
    assert xargs.partition(('cmd',), ()) == (('cmd',),)
Ejemplo n.º 18
0
def test_partition_limit_win32_py3(win32_py3_mock):
    cmd = ('ninechars', )
    # counted as half because of utf-16 encode
    varargs = ('😑' * 5, )
    ret = xargs.partition(cmd, varargs, 1, _max_length=21)
    assert ret == (cmd + varargs, )
Ejemplo n.º 19
0
def test_argument_too_long_with_large_unicode(linux_mock):
    cmd = ('ninechars',)
    varargs = ('😑' * 10,)  # 4 bytes * 10
    with pytest.raises(xargs.ArgumentTooLongError):
        xargs.partition(cmd, varargs, 1, _max_length=20)