<s> from __future__ import ( absolute_import , division , generators , nested_scopes , print_function , <EOL> unicode_literals , with_statement ) <EOL> import errno <EOL> import os <EOL> import mox <EOL> from pants . process . xargs import Xargs <EOL> class XargsTest ( mox . MoxTestBase ) : <EOL> def setUp ( self ) : <EOL> super ( XargsTest , self ) . setUp ( ) <EOL> self . call = self . mox . CreateMockAnything ( ) <EOL> self . xargs = Xargs ( self . call ) <EOL> def test_execute_nosplit_success ( self ) : <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , self . xargs . execute ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> def test_execute_nosplit_raise ( self ) : <EOL> exception = Exception ( ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . AndRaise ( exception ) <EOL> self . mox . ReplayAll ( ) <EOL> with self . assertRaises ( Exception ) as raised : <EOL> self . xargs . execute ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertIs ( exception , raised . exception ) <EOL> def test_execute_nosplit_fail ( self ) : <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT> ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <NUM_LIT> , self . xargs . execute ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> TOO_BIG = OSError ( errno . E2BIG , os . strerror ( errno . E2BIG ) ) <EOL> def test_execute_split ( self ) : <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . AndRaise ( self . TOO_BIG ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , self . xargs . execute ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> def test_execute_uneven ( self ) : <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . AndRaise ( self . TOO_BIG ) <EOL> self . call ( [ '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , self . xargs . execute ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> def test_execute_split_multirecurse ( self ) : <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . AndRaise ( self . TOO_BIG ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndRaise ( self . TOO_BIG ) <EOL> self . call ( [ '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . call ( [ '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , self . xargs . execute ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> def test_execute_split_fail_fast ( self ) : <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . AndRaise ( self . TOO_BIG ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT> ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <NUM_LIT> , self . xargs . execute ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> def test_execute_split_fail_slow ( self ) : <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . AndRaise ( self . TOO_BIG ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( <NUM_LIT> ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <NUM_LIT> , self . xargs . execute ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) </s>
