Beispiel #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,
    )
Beispiel #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,
    )
Beispiel #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,
    )
Beispiel #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,
    )
Beispiel #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),
    )
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)
def test_partition_limit_linux(linux_mock):
    cmd = ('ninechars', )
    varargs = ('😑' * 5, )
    ret = xargs.partition(cmd, varargs, 1, _max_length=31)
    assert ret == (cmd + varargs, )
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, )
def test_partition_simple():
    assert xargs.partition(('cmd', ), ('foo', ), 1) == (('cmd', 'foo'), )
Beispiel #10
0
def test_partition_simple():
    assert xargs.partition(('cmd',), ('foo',)) == (('cmd', 'foo'),)
Beispiel #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,)
Beispiel #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,)
Beispiel #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,)
Beispiel #14
0
def test_argument_too_long():
    with pytest.raises(xargs.ArgumentTooLongError):
        xargs.partition(('a' * 5, ), ('a' * 5, ), 1, _max_length=10)
Beispiel #15
0
def test_argument_too_long():
    with pytest.raises(xargs.ArgumentTooLongError):
        xargs.partition(('a' * 5,), ('a' * 5,), _max_length=10)
Beispiel #16
0
def test_partition_trivial():
    assert xargs.partition(('cmd', ), (), 1) == (('cmd', ), )
Beispiel #17
0
def test_partition_trivial():
    assert xargs.partition(('cmd',), ()) == (('cmd',),)
Beispiel #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, )
Beispiel #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)