Fixing Python 3 test incompatibility with builtins.

This commit is contained in:
Dan Helfman 2015-03-15 10:14:16 -07:00
parent aa48b95ee7
commit ee5697ac37
2 changed files with 8 additions and 3 deletions

View File

@ -28,7 +28,7 @@ def create_archive(excludes_filename, verbose, source_directories, repository):
try:
subprocess.check_output(command, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, error:
except subprocess.CalledProcessError as error:
print(error.output.strip(), file=sys.stderr)
if re.search('Error: Repository .* does not exist', error.output):

View File

@ -1,5 +1,10 @@
from collections import OrderedDict
import sys
try:
# Python 2
import __builtin__ as builtins
except ImportError:
# Python 3
import builtins
from flexmock import flexmock
from nose.tools import assert_raises
@ -23,7 +28,7 @@ def insert_subprocess_check_output_mock(call_command, error_output=None, **kwarg
if error_output:
expectation.and_raise(MockCalledProcessError, output=error_output)
flexmock(sys.modules['__builtin__']).should_receive('print')
flexmock(builtins).should_receive('print')
flexmock(module).subprocess = subprocess
return subprocess