mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
move sauce driver logic into isolated function, simplify selenium_driver
This commit is contained in:
parent
86ae162890
commit
bf39dec1ef
@ -63,26 +63,38 @@ def notebook_server():
|
|||||||
requests.post(urljoin(info['url'], 'api/shutdown'),
|
requests.post(urljoin(info['url'], 'api/shutdown'),
|
||||||
headers={'Authorization': 'token '+info['token']})
|
headers={'Authorization': 'token '+info['token']})
|
||||||
|
|
||||||
|
|
||||||
|
def make_sauce_driver():
|
||||||
|
"""This function helps travis create a driver on Sauce Labs.
|
||||||
|
|
||||||
|
This function will err if used without specifying the variables expected
|
||||||
|
in that context.
|
||||||
|
"""
|
||||||
|
|
||||||
|
username = os.environ["SAUCE_USERNAME"]
|
||||||
|
access_key = os.environ["SAUCE_ACCESS_KEY"]
|
||||||
|
capabilities = {
|
||||||
|
"tunnel-identifier": os.environ["TRAVIS_JOB_NUMBER"],
|
||||||
|
"build": os.environ["TRAVIS_BUILD_NUMBER"],
|
||||||
|
"tags": [os.environ['TRAVIS_PYTHON_VERSION'], 'CI'],
|
||||||
|
"platform": "Windows 10",
|
||||||
|
"browserName": os.environ['JUPYTER_TEST_BROWSER'],
|
||||||
|
"version": "latest",
|
||||||
|
}
|
||||||
|
if capabilities['browserName'] == 'firefox':
|
||||||
|
# Attempt to work around issue where browser loses authentication
|
||||||
|
capabilities['version'] = '57.0'
|
||||||
|
hub_url = "%s:%s@localhost:4445" % (username, access_key)
|
||||||
|
print("Connecting remote driver on Sauce Labs")
|
||||||
|
driver = Remote(desired_capabilities=capabilities,
|
||||||
|
command_executor="http://%s/wd/hub" % hub_url)
|
||||||
|
return driver
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def selenium_driver():
|
def selenium_driver():
|
||||||
if os.environ.get('SAUCE_USERNAME'):
|
if os.environ.get('SAUCE_USERNAME'):
|
||||||
username = os.environ["SAUCE_USERNAME"]
|
driver = make_sauce_driver()
|
||||||
access_key = os.environ["SAUCE_ACCESS_KEY"]
|
|
||||||
capabilities = {
|
|
||||||
"tunnel-identifier": os.environ["TRAVIS_JOB_NUMBER"],
|
|
||||||
"build": os.environ["TRAVIS_BUILD_NUMBER"],
|
|
||||||
"tags": [os.environ['TRAVIS_PYTHON_VERSION'], 'CI'],
|
|
||||||
"platform": "Windows 10",
|
|
||||||
"browserName": os.environ['JUPYTER_TEST_BROWSER'],
|
|
||||||
"version": "latest",
|
|
||||||
}
|
|
||||||
if capabilities['browserName'] == 'firefox':
|
|
||||||
# Attempt to work around issue where browser loses authentication
|
|
||||||
capabilities['version'] = '57.0'
|
|
||||||
hub_url = "%s:%s@localhost:4445" % (username, access_key)
|
|
||||||
print("Connecting remote driver on Sauce Labs")
|
|
||||||
driver = Remote(desired_capabilities=capabilities,
|
|
||||||
command_executor="http://%s/wd/hub" % hub_url)
|
|
||||||
elif os.environ.get('JUPYTER_TEST_BROWSER') == 'chrome':
|
elif os.environ.get('JUPYTER_TEST_BROWSER') == 'chrome':
|
||||||
driver = Chrome()
|
driver = Chrome()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user