Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Delayed initialization of Selenium webdrivers.

If setUpClass throws an exception (in this case "Address already in use" if the
super call can't find any open port to bind too) tearDownClass is not called.
This results in open browser windows from the webdriver, hence we only construct
it once we are sure there is no code afterwards which could error out.
  • Loading branch information...
commit 3c5775d36f7e431d9691829a78580873111cb714 1 parent bac86ad
Florian Apolloner authored September 14, 2013

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. 3  django/contrib/admin/tests.py
3  django/contrib/admin/tests.py
@@ -22,11 +22,12 @@ def setUpClass(cls):
22 22
         if not os.environ.get('DJANGO_SELENIUM_TESTS', False):
23 23
             raise SkipTest('Selenium tests not requested')
24 24
         try:
25  
-            cls.selenium = import_by_path(cls.webdriver_class)()
  25
+            webdriver_class = import_by_path(cls.webdriver_class)
26 26
         except Exception as e:
27 27
             raise SkipTest('Selenium webdriver "%s" not installed or not '
28 28
                            'operational: %s' % (cls.webdriver_class, str(e)))
29 29
         super(AdminSeleniumWebDriverTestCase, cls).setUpClass()
  30
+        cls.selenium = webdriver_class()
30 31
 
31 32
     @classmethod
32 33
     def tearDownClass(cls):

0 notes on commit 3c5775d

Please sign in to comment.
Something went wrong with that request. Please try again.