Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Only start a browser if we have to
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Sep 21, 2016
1 parent 1c3aa6a commit b57112c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions gratipay/testing/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
from .harness import Harness


def get_browser(driver_name):
# Override to clean up after ourselves properly.
DriverClass = _DRIVERS[driver_name]
driver = DriverClass()
atexit.register(driver.quit)
return driver


class BrowserHarness(Harness):
"""This is a harness for through-the-web (TTW) testing. It passes
everything through to an underlying `Splinter`_ browser, with the following
Expand All @@ -30,10 +22,20 @@ class BrowserHarness(Harness):
"""

_browser = get_browser(os.environ['WEBDRIVER_BROWSER'])
_browser = None
use_VCR = False # without this we get fixture spam from communication with PhantomJS
base_url = os.environ['WEBDRIVER_BASE_URL']

@classmethod
def setUpClass(cls):
super(BrowserHarness, cls).setUpClass()

# starting a browser is expensive, so we do so lazily, and once
if cls._browser is None:
DriverClass = _DRIVERS[os.environ['WEBDRIVER_BROWSER']]
cls._browser = DriverClass()
atexit.register(cls._browser.quit)

def setUp(self):
Harness.setUp(self)
self.cookies.delete()
Expand Down

0 comments on commit b57112c

Please sign in to comment.