<s> from __future__ import unicode_literals <EOL> import sys <EOL> import unittest <EOL> from django . test import LiveServerTestCase , tag <EOL> from django . utils . module_loading import import_string <EOL> from django . utils . six import with_metaclass <EOL> from django . utils . text import capfirst <EOL> class SeleniumTestCaseBase ( type ( LiveServerTestCase ) ) : <EOL> browsers = [ ] <EOL> browser = None <EOL> def __new__ ( cls , name , bases , attrs ) : <EOL> """<STR_LIT>""" <EOL> test_class = super ( SeleniumTestCaseBase , cls ) . __new__ ( cls , name , bases , attrs ) <EOL> if test_class . browser or not any ( name . startswith ( '<STR_LIT:test>' ) and callable ( value ) for name , value in attrs . items ( ) ) : <EOL> return test_class <EOL> elif test_class . browsers : <EOL> first_browser = test_class . browsers [ <NUM_LIT:0> ] <EOL> test_class . browser = first_browser <EOL> module = sys . modules [ test_class . __module__ ] <EOL> for browser in test_class . browsers [ <NUM_LIT:1> : ] : <EOL> browser_test_class = cls . __new__ ( <EOL> cls , <EOL> str ( "<STR_LIT>" % ( capfirst ( browser ) , name ) ) , <EOL> ( test_class , ) , <EOL> { '<STR_LIT>' : browser , '<STR_LIT>' : test_class . __module__ } <EOL> ) <EOL> setattr ( module , browser_test_class . __name__ , browser_test_class ) <EOL> return test_class <EOL> return unittest . skip ( '<STR_LIT>' ) ( test_class ) <EOL> @ classmethod <EOL> def import_webdriver ( cls , browser ) : <EOL> return import_string ( "<STR_LIT>" % browser ) <EOL> def create_webdriver ( self ) : <EOL> return self . import_webdriver ( self . browser ) ( ) <EOL> @ tag ( '<STR_LIT>' ) <EOL> class SeleniumTestCase ( with_metaclass ( SeleniumTestCaseBase , LiveServerTestCase ) ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . selenium = cls . create_webdriver ( ) <EOL> cls . selenium . implicitly_wait ( <NUM_LIT:10> ) <EOL> super ( SeleniumTestCase , cls ) . setUpClass ( ) <EOL> @ classmethod <EOL> def _tearDownClassInternal ( cls ) : <EOL> if hasattr ( cls , '<STR_LIT>' ) : <EOL> cls . selenium . quit ( ) <EOL> super ( SeleniumTestCase , cls ) . _tearDownClassInternal ( ) </s>
