Browse files

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


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 e2ac020 from master
  • Loading branch information...
1 parent 5f04240 commit c9014a95bc9fb37d8e380f65f7926dadc598c8e7 @timgraham timgraham committed Mar 27, 2014
Showing with 7 additions and 7 deletions.
  1. +7 −7 tests/view_tests/tests/
@@ -11,13 +11,9 @@
LiveServerTestCase, TestCase, modify_settings, override_settings)
from django.utils import six
from django.utils._os import upath
+from django.utils.module_loading import import_string
from django.utils.translation import override, LANGUAGE_SESSION_KEY
- from selenium.webdriver.firefox import webdriver as firefox
-except ImportError:
- firefox = None
from ..urls import locale_dir
@@ -211,16 +207,20 @@ def testI18NWithLocalePaths(self):
@unittest.skipIf(skip_selenium, 'Selenium tests not requested')
-@unittest.skipUnless(firefox, 'Selenium not installed')
class JavascriptI18nTests(LiveServerTestCase):
# The test cases use translations from these apps.
available_apps = ['django.contrib.admin', 'view_tests']
urls = 'view_tests.urls'
+ webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
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()

0 comments on commit c9014a9

Please sign in to comment.