Merge "Avoid ImportError when selenium is missing."

This commit is contained in:
Jenkins 2013-07-08 17:17:46 +00:00 committed by Gerrit Code Review
commit 46ebda3d5d
1 changed files with 14 additions and 2 deletions

View File

@ -18,6 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import os
import socket
@ -32,8 +33,19 @@ from django import test as django_test
from django.test.client import RequestFactory
from django.utils import unittest
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.support import ui as selenium_ui
LOG = logging.getLogger(__name__)
try:
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.support import ui as selenium_ui
except ImportError as e:
# NOTE(saschpe): Several distribution can't ship selenium due to it's
# non-free license. So they have to patch it out of test-requirements.txt
# Avoid import failure and force not running selenium tests.
LOG.warning("{0}, force WITH_SELENIUM=False".format(str(e)))
os.environ['WITH_SELENIUM'] = ''
import mox