Fix: "__builtin__" issue for Python 2/3 compatible code
replace __builtin__ with six.moves.builtins Story: 2003433 Task: 28473 Change-Id: I03a601b04229495f4dccd1fb712288d7a7493552 Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
68f4fa3c42
commit
68c67e50fa
|
@ -32,5 +32,5 @@ eventlet.monkey_patch(os=False)
|
|||
|
||||
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
||||
# The code below enables nosetests to work with i18n _() blocks
|
||||
import __builtin__
|
||||
setattr(__builtin__, '_', lambda x: x)
|
||||
from six.moves import builtins
|
||||
setattr(builtins, '_', lambda x: x)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import __builtin__
|
||||
import errno
|
||||
import hashlib
|
||||
import os
|
||||
|
@ -27,6 +26,7 @@ import netaddr
|
|||
from oslo_config import cfg
|
||||
|
||||
from six import StringIO
|
||||
from six.moves import builtins
|
||||
from sysinv.common import exception
|
||||
from sysinv.common import utils
|
||||
from sysinv.tests import base
|
||||
|
@ -195,7 +195,7 @@ class GenericUtilsTestCase(base.TestCase):
|
|||
|
||||
def test_read_modified_cached_file(self):
|
||||
self.mox.StubOutWithMock(os.path, "getmtime")
|
||||
self.mox.StubOutWithMock(__builtin__, 'open')
|
||||
self.mox.StubOutWithMock(builtins, 'open')
|
||||
os.path.getmtime(mox.IgnoreArg()).AndReturn(2)
|
||||
|
||||
fake_contents = "lorem ipsum"
|
||||
|
@ -207,7 +207,7 @@ class GenericUtilsTestCase(base.TestCase):
|
|||
mox.IgnoreArg(),
|
||||
mox.IgnoreArg())
|
||||
|
||||
__builtin__.open(mox.IgnoreArg()).AndReturn(fake_context_manager)
|
||||
builtins.open(mox.IgnoreArg()).AndReturn(fake_context_manager)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
cache_data = {"data": 1123, "mtime": 1}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
__all__ = ['main']
|
||||
|
||||
import __builtin__ as builtins
|
||||
from six.moves import builtins
|
||||
import sys
|
||||
|
||||
import pyflakes.api
|
||||
|
|
Loading…
Reference in New Issue