Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

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
@apollo13 apollo13 authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  django/contrib/admin/
3  django/contrib/admin/
@@ -22,11 +22,12 @@ def setUpClass(cls):
if not os.environ.get('DJANGO_SELENIUM_TESTS', False):
raise SkipTest('Selenium tests not requested')
- cls.selenium = import_by_path(cls.webdriver_class)()
+ webdriver_class = import_by_path(cls.webdriver_class)
except Exception as e:
raise SkipTest('Selenium webdriver "%s" not installed or not '
'operational: %s' % (cls.webdriver_class, str(e)))
super(AdminSeleniumWebDriverTestCase, cls).setUpClass()
+ cls.selenium = webdriver_class()
def tearDownClass(cls):

0 comments on commit 3c5775d

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