Allow mox-free horizon plugins to consume horizon test helper

horizon test helpers now depend on mox3.
This prevents horizon plugins from consuming the test helpers
even if a plugin itself is mox free.
This commit makes mox import optional.

Change-Id: I631518d8f4cd9641920f68cd1e405298ddb7965a
Closes-Bug: #1753555
This commit is contained in:
Akihiro Motoki 2018-03-06 03:44:31 +09:00
parent d4c1c29cbb
commit fb9ef26a7b
2 changed files with 16 additions and 3 deletions

View File

@ -55,8 +55,14 @@ except ImportError as e:
LOG.warning("%s, force WITH_SELENIUM=False", e)
os.environ['WITH_SELENIUM'] = ''
from mox3 import mox
# As of Rocky, we are in the process of removing mox usage.
# To allow mox-free horizon plugins to consume the test helper,
# mox import is now optional. If tests depends on mox,
# mox (or mox3) must be declared in test-requirements.txt.
try:
from mox3 import mox
except ImportError:
pass
from horizon import middleware

View File

@ -38,8 +38,15 @@ from django.utils import http
from cinderclient import client as cinder_client
import glanceclient
from keystoneclient.v2_0 import client as keystone_client
# As of Rocky, we are in the process of removing mox usage.
# To allow mox-free horizon plugins to consume the test helper,
# mox import is now optional. If tests depends on mox,
# mox (or mox3) must be declared in test-requirements.txt.
import mock
from mox3 import mox
try:
from mox3 import mox
except ImportError:
pass
from neutronclient.v2_0 import client as neutron_client
from novaclient import api_versions as nova_api_versions
from novaclient.v2 import client as nova_client