Python 3: fix usage of reload()
Replace reload() builtin function with six.moves.reload_module() to make the code compatible with Python 2 and Python 3. Change-Id: I7572d613fef700b392d412501facc3bd5ee72a66
This commit is contained in:
parent
574a666a43
commit
e6776306b7
@ -17,6 +17,7 @@
|
||||
|
||||
import os
|
||||
from six import StringIO
|
||||
from six.moves import reload_module
|
||||
import unittest
|
||||
from getpass import getuser
|
||||
import logging
|
||||
@ -69,7 +70,7 @@ class TestRunDaemon(unittest.TestCase):
|
||||
utils.capture_stdio = lambda *args: None
|
||||
|
||||
def tearDown(self):
|
||||
reload(utils)
|
||||
reload_module(utils)
|
||||
|
||||
def test_run(self):
|
||||
d = MyDaemon({})
|
||||
|
@ -21,12 +21,14 @@ import logging
|
||||
import errno
|
||||
import math
|
||||
import time
|
||||
from mock import patch, call
|
||||
from shutil import rmtree, copy
|
||||
from tempfile import mkdtemp, NamedTemporaryFile
|
||||
import mock
|
||||
import json
|
||||
|
||||
import mock
|
||||
from mock import patch, call
|
||||
from six.moves import reload_module
|
||||
|
||||
from swift.container.backend import DATADIR
|
||||
from swift.common import db_replicator
|
||||
from swift.common.utils import (normalize_timestamp, hash_path,
|
||||
@ -44,7 +46,7 @@ TEST_CONTAINER_NAME = 'c o n'
|
||||
|
||||
def teardown_module():
|
||||
"clean up my monkey patching"
|
||||
reload(db_replicator)
|
||||
reload_module(db_replicator)
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
@ -24,6 +24,8 @@ import errno
|
||||
from collections import defaultdict
|
||||
from time import sleep, time
|
||||
|
||||
from six.moves import reload_module
|
||||
|
||||
from swift.common import manager
|
||||
from swift.common.exceptions import InvalidPidFileException
|
||||
|
||||
@ -283,7 +285,7 @@ class TestManagerModule(unittest.TestCase):
|
||||
class TestServer(unittest.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
reload(manager)
|
||||
reload_module(manager)
|
||||
|
||||
def join_swift_dir(self, path):
|
||||
return os.path.join(manager.SWIFT_DIR, path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user