py3: replace reload with six.moves.reload_module

Get the reload() function from six.moves.reload_module().

Partial-Implements: blueprint porting-python3
Change-Id: I063f83ac7e51c47d8c0172f0de4ae944fb11aa61
This commit is contained in:
Victor Stinner 2015-08-20 10:19:03 -07:00
parent 3b67a817c8
commit f62241675f
2 changed files with 7 additions and 5 deletions

View File

@ -22,6 +22,7 @@ from django.contrib.auth.models import User # noqa
from django.core.exceptions import ImproperlyConfigured # noqa
from django.core import urlresolvers
from django.utils.importlib import import_module # noqa
from six import moves
import horizon
from horizon import base
@ -101,7 +102,7 @@ class BaseHorizonTests(test.TestCase):
del base.Horizon
base.Horizon = base.HorizonSite()
# Reload the convenience references to Horizon stored in __init__
reload(import_module("horizon"))
moves.reload_module(import_module("horizon"))
# Re-register our original dashboards and panels.
# This is necessary because autodiscovery only works on the first
# import, and calling reload introduces innumerable additional
@ -120,7 +121,7 @@ class BaseHorizonTests(test.TestCase):
only for testing and should never be used on a live site.
"""
urlresolvers.clear_url_caches()
reload(import_module(settings.ROOT_URLCONF))
moves.reload_module(import_module(settings.ROOT_URLCONF))
base.Horizon._urls()
@ -490,7 +491,7 @@ class RbacHorizonTests(test.TestCase):
del base.Horizon
base.Horizon = base.HorizonSite()
# Reload the convenience references to Horizon stored in __init__
reload(import_module("horizon"))
moves.reload_module(import_module("horizon"))
# Reset Cats and Dogs default_panel to default values
Cats.default_panel = 'kittens'

View File

@ -43,6 +43,7 @@ from neutronclient.v2_0 import client as neutron_client
from novaclient.v2 import client as nova_client
from openstack_auth import user
from openstack_auth import utils
from six import moves
from swiftclient import client as swift_client
from horizon import base
@ -530,7 +531,7 @@ class PluginTestCase(TestCase):
del base.Horizon
base.Horizon = base.HorizonSite()
# Reload the convenience references to Horizon stored in __init__
reload(import_module("horizon"))
moves.reload_module(import_module("horizon"))
# Re-register our original dashboards and panels.
# This is necessary because autodiscovery only works on the first
# import, and calling reload introduces innumerable additional
@ -550,7 +551,7 @@ class PluginTestCase(TestCase):
only for testing and should never be used on a live site.
"""
urlresolvers.clear_url_caches()
reload(import_module(settings.ROOT_URLCONF))
moves.reload_module(import_module(settings.ROOT_URLCONF))
base.Horizon._urls()