File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 2323import sys
2424import tempfile
2525import time
26- from nose .tools import eq_ , ok_ , with_setup
26+ from nose .tools import eq_ , ok_ , with_setup , assert_raises
2727
2828import vagrant
2929from vagrant import compat
@@ -552,6 +552,9 @@ def test_streaming_output():
552552 test_string = 'Waiting for machine to boot.'
553553 v = vagrant .Vagrant (TD )
554554
555+ with assert_raises (subprocess .CalledProcessError ):
556+ v .up (vm_name = 'incorrect-name' )
557+
555558 streaming_up = False
556559 for line in v .up (stream_output = True ):
557560 print ('output line:' , line )
Original file line number Diff line number Diff line change @@ -993,19 +993,16 @@ def _stream_vagrant_command(self, args):
993993 sp_args = dict (args = command , cwd = self .root , env = self .env ,
994994 stdout = subprocess .PIPE , stderr = err_fh , bufsize = 1 )
995995
996- # Method to iterate over output lines depends on version of Python .
996+ # Iterate over output lines.
997997 # See http://stackoverflow.com/questions/2715847/python-read-streaming-input-from-subprocess-communicate#17698359
998- if not py3 : # Python 2.x
999- p = subprocess .Popen (** sp_args )
1000- with p .stdout :
1001- for line in iter (p .stdout .readline , b'' ):
1002- yield line
1003- p .wait ()
1004- else : # Python 3.0+
1005- with subprocess .Popen (** sp_args ) as p :
1006- for line in p .stdout :
1007- yield line
1008-
998+ p = subprocess .Popen (** sp_args )
999+ with p .stdout :
1000+ for line in iter (p .stdout .readline , b'' ):
1001+ yield compat .decode (line ) # if PY3 decode bytestrings
1002+ p .wait ()
1003+ # Raise CalledProcessError for consistency with _call_vagrant_command
1004+ if p .returncode != 0 :
1005+ raise subprocess .CalledProcessError (p .returncode , command )
10091006
10101007
10111008class SandboxVagrant (Vagrant ):
You can’t perform that action at this time.
0 commit comments