@@ -36,11 +36,11 @@ def linux_mock():
3636
3737
3838def test_partition_trivial ():
39- assert xargs .partition (('cmd' ,), ()) == (('cmd' ,),)
39+ assert xargs .partition (('cmd' ,), (), 1 ) == (('cmd' ,),)
4040
4141
4242def test_partition_simple ():
43- assert xargs .partition (('cmd' ,), ('foo' ,)) == (('cmd' , 'foo' ),)
43+ assert xargs .partition (('cmd' ,), ('foo' ,), 1 ) == (('cmd' , 'foo' ),)
4444
4545
4646def test_partition_limits ():
@@ -54,6 +54,7 @@ def test_partition_limits():
5454 '.' * 5 ,
5555 '.' * 6 ,
5656 ),
57+ 1 ,
5758 _max_length = 20 ,
5859 )
5960 assert ret == (
@@ -68,34 +69,61 @@ def test_partition_limit_win32_py3(win32_py3_mock):
6869 cmd = ('ninechars' ,)
6970 # counted as half because of utf-16 encode
7071 varargs = ('😑' * 5 ,)
71- ret = xargs .partition (cmd , varargs , _max_length = 20 )
72+ ret = xargs .partition (cmd , varargs , 1 , _max_length = 20 )
7273 assert ret == (cmd + varargs ,)
7374
7475
7576def test_partition_limit_win32_py2 (win32_py2_mock ):
7677 cmd = ('ninechars' ,)
7778 varargs = ('😑' * 5 ,) # 4 bytes * 5
78- ret = xargs .partition (cmd , varargs , _max_length = 30 )
79+ ret = xargs .partition (cmd , varargs , 1 , _max_length = 30 )
7980 assert ret == (cmd + varargs ,)
8081
8182
8283def test_partition_limit_linux (linux_mock ):
8384 cmd = ('ninechars' ,)
8485 varargs = ('😑' * 5 ,)
85- ret = xargs .partition (cmd , varargs , _max_length = 30 )
86+ ret = xargs .partition (cmd , varargs , 1 , _max_length = 30 )
8687 assert ret == (cmd + varargs ,)
8788
8889
8990def test_argument_too_long_with_large_unicode (linux_mock ):
9091 cmd = ('ninechars' ,)
9192 varargs = ('😑' * 10 ,) # 4 bytes * 10
9293 with pytest .raises (xargs .ArgumentTooLongError ):
93- xargs .partition (cmd , varargs , _max_length = 20 )
94+ xargs .partition (cmd , varargs , 1 , _max_length = 20 )
95+
96+
97+ def test_partition_target_concurrency ():
98+ ret = xargs .partition (
99+ ('foo' ,), ('A' ,) * 22 ,
100+ 4 ,
101+ _max_length = 50 ,
102+ )
103+ assert ret == (
104+ ('foo' ,) + ('A' ,) * 6 ,
105+ ('foo' ,) + ('A' ,) * 6 ,
106+ ('foo' ,) + ('A' ,) * 6 ,
107+ ('foo' ,) + ('A' ,) * 4 ,
108+ )
109+
110+
111+ def test_partition_target_concurrency_wont_make_tiny_partitions ():
112+ ret = xargs .partition (
113+ ('foo' ,), ('A' ,) * 10 ,
114+ 4 ,
115+ _max_length = 50 ,
116+ )
117+ assert ret == (
118+ ('foo' ,) + ('A' ,) * 4 ,
119+ ('foo' ,) + ('A' ,) * 4 ,
120+ ('foo' ,) + ('A' ,) * 2 ,
121+ )
94122
95123
96124def test_argument_too_long ():
97125 with pytest .raises (xargs .ArgumentTooLongError ):
98- xargs .partition (('a' * 5 ,), ('a' * 5 ,), _max_length = 10 )
126+ xargs .partition (('a' * 5 ,), ('a' * 5 ,), 1 , _max_length = 10 )
99127
100128
101129def test_xargs_smoke ():
0 commit comments