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:
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from six import StringIO
|
from six import StringIO
|
||||||
|
from six.moves import reload_module
|
||||||
import unittest
|
import unittest
|
||||||
from getpass import getuser
|
from getpass import getuser
|
||||||
import logging
|
import logging
|
||||||
@@ -69,7 +70,7 @@ class TestRunDaemon(unittest.TestCase):
|
|||||||
utils.capture_stdio = lambda *args: None
|
utils.capture_stdio = lambda *args: None
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
reload(utils)
|
reload_module(utils)
|
||||||
|
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
d = MyDaemon({})
|
d = MyDaemon({})
|
||||||
|
@@ -21,12 +21,14 @@ import logging
|
|||||||
import errno
|
import errno
|
||||||
import math
|
import math
|
||||||
import time
|
import time
|
||||||
from mock import patch, call
|
|
||||||
from shutil import rmtree, copy
|
from shutil import rmtree, copy
|
||||||
from tempfile import mkdtemp, NamedTemporaryFile
|
from tempfile import mkdtemp, NamedTemporaryFile
|
||||||
import mock
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
import mock
|
||||||
|
from mock import patch, call
|
||||||
|
from six.moves import reload_module
|
||||||
|
|
||||||
from swift.container.backend import DATADIR
|
from swift.container.backend import DATADIR
|
||||||
from swift.common import db_replicator
|
from swift.common import db_replicator
|
||||||
from swift.common.utils import (normalize_timestamp, hash_path,
|
from swift.common.utils import (normalize_timestamp, hash_path,
|
||||||
@@ -44,7 +46,7 @@ TEST_CONTAINER_NAME = 'c o n'
|
|||||||
|
|
||||||
def teardown_module():
|
def teardown_module():
|
||||||
"clean up my monkey patching"
|
"clean up my monkey patching"
|
||||||
reload(db_replicator)
|
reload_module(db_replicator)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
@@ -24,6 +24,8 @@ import errno
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
|
|
||||||
|
from six.moves import reload_module
|
||||||
|
|
||||||
from swift.common import manager
|
from swift.common import manager
|
||||||
from swift.common.exceptions import InvalidPidFileException
|
from swift.common.exceptions import InvalidPidFileException
|
||||||
|
|
||||||
@@ -283,7 +285,7 @@ class TestManagerModule(unittest.TestCase):
|
|||||||
class TestServer(unittest.TestCase):
|
class TestServer(unittest.TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
reload(manager)
|
reload_module(manager)
|
||||||
|
|
||||||
def join_swift_dir(self, path):
|
def join_swift_dir(self, path):
|
||||||
return os.path.join(manager.SWIFT_DIR, path)
|
return os.path.join(manager.SWIFT_DIR, path)
|
||||||
|
Reference in New Issue
Block a user