Kaydet (Commit) c9014a95 authored tarafından Tim Graham's avatar Tim Graham

[1.7.x] Skipped JavascriptI18nTests if Firefox isn't properly configured.

Code borrowed from django.contrib.admin.tests. Without this, the class can
throw an exception with something like "The browser appears to have exited
before we could connect. The output was: Error: no display specified"

Backport of e2ac0203 from master
üst 5f042403
...@@ -11,13 +11,9 @@ from django.test import ( ...@@ -11,13 +11,9 @@ from django.test import (
LiveServerTestCase, TestCase, modify_settings, override_settings) LiveServerTestCase, TestCase, modify_settings, override_settings)
from django.utils import six from django.utils import six
from django.utils._os import upath from django.utils._os import upath
from django.utils.module_loading import import_string
from django.utils.translation import override, LANGUAGE_SESSION_KEY from django.utils.translation import override, LANGUAGE_SESSION_KEY
try:
from selenium.webdriver.firefox import webdriver as firefox
except ImportError:
firefox = None
from ..urls import locale_dir from ..urls import locale_dir
...@@ -211,16 +207,20 @@ skip_selenium = not os.environ.get('DJANGO_SELENIUM_TESTS', False) ...@@ -211,16 +207,20 @@ skip_selenium = not os.environ.get('DJANGO_SELENIUM_TESTS', False)
@unittest.skipIf(skip_selenium, 'Selenium tests not requested') @unittest.skipIf(skip_selenium, 'Selenium tests not requested')
@unittest.skipUnless(firefox, 'Selenium not installed')
class JavascriptI18nTests(LiveServerTestCase): class JavascriptI18nTests(LiveServerTestCase):
# The test cases use translations from these apps. # The test cases use translations from these apps.
available_apps = ['django.contrib.admin', 'view_tests'] available_apps = ['django.contrib.admin', 'view_tests']
urls = 'view_tests.urls' urls = 'view_tests.urls'
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.selenium = firefox.WebDriver() try:
cls.selenium = import_string(cls.webdriver_class)()
except Exception as e:
raise unittest.SkipTest('Selenium webdriver "%s" not installed or '
'not operational: %s' % (cls.webdriver_class, str(e)))
super(JavascriptI18nTests, cls).setUpClass() super(JavascriptI18nTests, cls).setUpClass()
@classmethod @classmethod
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment