def test_wait_status(test): """Tests wait() return value.""" assert sh.true().execute(wait = False).wait() == 0 assert sh.true().execute(wait = False).wait(check_status = True) == 0 assert sh.false().execute(wait = False).wait() == 1 assert pytest.raises(psh.ExecutionError, lambda: sh.false().execute(wait = False).wait(check_status = True)).value.status() == 1
def test_wait_status(test): """Tests wait() return value.""" assert sh.true().execute(wait=False).wait() == 0 assert sh.true().execute(wait=False).wait(check_status=True) == 0 assert sh.false().execute(wait=False).wait() == 1 assert pytest.raises( psh.ExecutionError, lambda: sh.false().execute(wait=False).wait( check_status=True)).value.status() == 1
def test_ok_statuses(test): """Tests _ok_statuses option.""" assert sh.false(_ok_statuses=(0, 1)).execute().status() == 1 assert pytest.raises( psh.ExecutionError, lambda: sh.true(_ok_statuses=[]).execute()).value.status() == 0
def test_error_codes(test): """Tests error codes.""" sh.sh("-c", sh.true(), _shell=True).execute().status() == 0 assert pytest.raises(psh.ExecutionError, lambda: sh.sh("-c", sh.false(), _shell=True).execute()).value.status() == 1 pipe = sh.cat() | sh.egrep("bbb|ccc") | sh.grep("ccc") assert pytest.raises(psh.ExecutionError, lambda: sh.sh("-c", pipe, _stdin="aaa\n", _shell=True).execute()).value.status() == 128 assert pytest.raises(psh.ExecutionError, lambda: sh.sh("-c", pipe, _stdin="bbb\n", _shell=True).execute()).value.status() == 1
def test_error_codes(test): """Tests error codes.""" sh.sh("-c", sh.true(), _shell=True).execute().status() == 0 assert pytest.raises( psh.ExecutionError, lambda: sh.sh("-c", sh.false(), _shell=True). execute()).value.status() == 1 pipe = sh.cat() | sh.egrep("bbb|ccc") | sh.grep("ccc") assert pytest.raises( psh.ExecutionError, lambda: sh.sh("-c", pipe, _stdin="aaa\n", _shell=True).execute( )).value.status() == 128 assert pytest.raises( psh.ExecutionError, lambda: sh.sh("-c", pipe, _stdin="bbb\n", _shell=True).execute( )).value.status() == 1
def test_nonzero_exit_status(test): """Tests nonzero exit status.""" assert pytest.raises(psh.ExecutionError, lambda: sh.false().execute()).value.status() == 1
def test_ok_statuses(test): """Tests _ok_statuses option.""" assert sh.false(_ok_statuses = [ 0, 1 ] ).execute().status() == 1 assert pytest.raises(psh.ExecutionError, lambda: sh.true(_ok_statuses = []).execute()).value.status() == 0