# @license
# Copyright 2020 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import atexit
import pytest
import neuroglancer.webdriver

def pytest_addoption(parser):
    parser.addoption('--headless',
                     action='store_true',
                     default=False,
                     help='Run Chrome browser headless')
    parser.addoption('--debug-webdriver',
                     action='store_true',
                     default=False,
                     help='Show webdriver debug logs')
    parser.addoption('--webdriver-docker',
                     action='store_true',
                     default=False,
                     help='Use webdriver configuration that supports running inside docker')
    parser.addoption('--static-content-url',
                     default=None,
                     help='URL to Neuroglancer Python client')
    parser.addoption('--browser',
                     choices=['chrome', 'firefox'],
                     default='chrome',
                     help='Specifies the browser to use.')


@pytest.fixture(scope='session')
def _webdriver_internal(request):
    static_content_url = request.config.getoption('--static-content-url')
    if static_content_url is not None:
        neuroglancer.set_static_content_source(url=static_content_url)
    webdriver = neuroglancer.webdriver.Webdriver(
        headless=request.config.getoption('--headless'),
        docker=request.config.getoption('--webdriver-docker'),
        debug=request.config.getoption('--debug-webdriver'),
        browser=request.config.getoption('--browser'),
    )
    atexit.register(webdriver.driver.close)
    return webdriver

@pytest.fixture
def webdriver(_webdriver_internal):
    viewer = _webdriver_internal.viewer
    viewer.set_state({})
    viewer.actions.clear()
    viewer.config_state.set_state({})
    return _webdriver_internal

@@ -637,16 +637,17 @@
 driver%0A%0A
+%0A
 def pyte
@@ -1275,64 +1275,22 @@
 rl',
-%0A                     default=None,%0A                    
+ default=None,
  hel
@@ -1516,76 +1516,368 @@
 .')%0A
-%0A%0A@pytest.fixture(scope='session')%0Adef _webdriver_internal(request):
+    parser.addoption('--skip-browser-tests',%0A                     action='store_true',%0A                     default=False,%0A                     help='Skip tests that rely on a web browser.')%0A%0A%0A@pytest.fixture(scope='session')%0Adef _webdriver_internal(request):%0A    if request.config.getoption('--skip-browser-tests'):%0A        pytest.skip('--skip-browser-tests')
 %0A   
@@ -2415,16 +2415,17 @@
 driver%0A%0A
+%0A
 @pytest.

add option to skip browser tests