Fixing Python 3 test incompatibility with builtins.
This commit is contained in:
parent
04216922c4
commit
a5eda0d305
2 changed files with 8 additions and 3 deletions
|
@ -28,7 +28,7 @@ def create_archive(excludes_filename, verbose, source_directories, repository):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_output(command, stderr=subprocess.STDOUT)
|
subprocess.check_output(command, stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError, error:
|
except subprocess.CalledProcessError as error:
|
||||||
print(error.output.strip(), file=sys.stderr)
|
print(error.output.strip(), file=sys.stderr)
|
||||||
|
|
||||||
if re.search('Error: Repository .* does not exist', error.output):
|
if re.search('Error: Repository .* does not exist', error.output):
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import sys
|
try:
|
||||||
|
# Python 2
|
||||||
|
import __builtin__ as builtins
|
||||||
|
except ImportError:
|
||||||
|
# Python 3
|
||||||
|
import builtins
|
||||||
|
|
||||||
from flexmock import flexmock
|
from flexmock import flexmock
|
||||||
from nose.tools import assert_raises
|
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:
|
if error_output:
|
||||||
expectation.and_raise(MockCalledProcessError, output=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
|
flexmock(module).subprocess = subprocess
|
||||||
return subprocess
|
return subprocess
|
||||||
|
|
Loading…
Reference in a new issue