def _print_logs_on_failure(cls): if cls._failure_occurred: cls.log.info('\n'.join([ '', '\t\tFailed test!', '\t\tCaptured logging:', ])) GlobalMemoryHandler.rotate_buffer(1) GlobalMemoryHandler.flush_to_target() browser_logger = get_wrapped_logger(name=cls.__name__ + '.driver', log_level=logging.DEBUG) if cls.show_driver_logs: cls.log.info('\n\t\tjavascript console logs below...\n\n') for entry in cls.driver.get_log('browser'): level = logging._nameToLevel.get(entry['level'], logging.ERROR) msg = entry['message'].strip() browser_logger.log(level, msg) record, target = GlobalMemoryHandler._buffer[-1] record.ct = entry['timestamp'] / 1000. GlobalMemoryHandler._buffer[-1] = record, target GlobalMemoryHandler.flush_to_target() if (not cls._failure_occurred) or os.environ.get('CI'): cls.log.info('closing webdriver') cls.driver.quit() else: cls.log.info('keeping webdriver open')
def init_webdriver(cls): cls.log = get_wrapped_logger(cls.__name__) _skip_if_no_selenium() if hasattr(cls, 'driver'): return cls.driver if (os.environ.get('CI') and os.environ.get('TRAVIS') and os.environ.get('SAUCE_ACCESS_KEY')): cls.log.info( 'Running in CI environment. Using Sauce remote webdriver.') username = os.environ['SAUCE_USERNAME'] access_key = os.environ['SAUCE_ACCESS_KEY'] capabilities = { # 'platform': 'Mac OS X 10.9', 'platform': 'Linux', 'browserName': 'firefox', 'version': 'latest', 'tags': [os.environ['TOXENV'], 'CI'], 'name': cls.__name__ } hub_url = 'http://{}:{}@ondemand.saucelabs.com:80/wd/hub'.format( username, access_key) if os.environ.get('TRAVIS'): # see https://docs.travis-ci.com/user/gui-and-headless-browsers # and https://docs.travis-ci.com/user/sauce-connect capabilities.update({ 'tunnel-identifier': os.environ['TRAVIS_JOB_NUMBER'], 'build': os.environ['TRAVIS_BUILD_NUMBER'], }) cls.driver = webdriver.Remote( desired_capabilities=capabilities, command_executor=hub_url) else: cls.log.info('Using local webdriver.') cls.driver = webdriver.Firefox() return cls.driver
def _print_logs_on_failure(cls): if cls._failure_occurred: cls.log.info('\n'.join([ '', '\t\tFailed test!', '\t\tCaptured logging:', ])) GlobalMemoryHandler.rotate_buffer(1) GlobalMemoryHandler.flush_to_target() browser_logger = get_wrapped_logger( name=cls.__name__ + '.driver', log_level=logging.DEBUG) if cls.show_driver_logs: cls.log.info('\n\t\tjavascript console logs below...\n\n') for entry in cls.driver.get_log('browser'): level = logging._nameToLevel.get( entry['level'], logging.ERROR) msg = entry['message'].strip() browser_logger.log(level, msg) record, target = GlobalMemoryHandler._buffer[-1] record.ct = entry['timestamp'] / 1000. GlobalMemoryHandler._buffer[-1] = record, target GlobalMemoryHandler.flush_to_target() if (not cls._failure_occurred) or os.environ.get('CI'): cls.log.info('closing webdriver') cls.driver.quit() else: cls.log.info('keeping webdriver open')
def init_webdriver(cls): cls.log = get_wrapped_logger(cls.__name__) _skip_if_no_selenium() if hasattr(cls, 'driver'): return cls.driver if (os.environ.get('CI') and os.environ.get('TRAVIS') and os.environ.get('SAUCE_ACCESS_KEY')): cls.log.info( 'Running in CI environment. Using Sauce remote webdriver.') username = os.environ['SAUCE_USERNAME'] access_key = os.environ['SAUCE_ACCESS_KEY'] capabilities = { # 'platform': 'Mac OS X 10.9', 'platform': 'Linux', 'browserName': 'firefox', 'version': 'latest', 'tags': [os.environ['TOXENV'], 'CI'], 'name': cls.__name__ } hub_url = 'http://{}:{}@ondemand.saucelabs.com:80/wd/hub'.format( username, access_key) if os.environ.get('TRAVIS'): # see https://docs.travis-ci.com/user/gui-and-headless-browsers # and https://docs.travis-ci.com/user/sauce-connect capabilities.update({ 'tunnel-identifier': os.environ['TRAVIS_JOB_NUMBER'], 'build': os.environ['TRAVIS_BUILD_NUMBER'], }) cls.driver = webdriver.Remote( desired_capabilities=capabilities, command_executor=hub_url) else: cls.log.info('Using local webdriver.') cls.driver = webdriver.Firefox() return cls.driver
def pre_server_setup(cls): """Setup extensions etc before running the notebook server.""" # added to install things! cls.log.info('Enabling jupyter_nbextensions_configurator') inst_func = serverextensions.toggle_serverextension_python inst_funcname = '.'.join([inst_func.__module__, inst_func.__name__]) logger = get_wrapped_logger( name=inst_funcname, log_level=logging.DEBUG) serverextensions.toggle_serverextension_python( 'jupyter_nbextensions_configurator', enabled=True, logger=logger, user=cls._install_user, sys_prefix=cls._install_sys_prefix)
def pre_server_setup(cls): """Setup extensions etc before running the notebook server.""" # added to install things! cls.log.info('Enabling jupyter_nbextensions_configurator') inst_func = serverextensions.toggle_serverextension_python inst_funcname = '.'.join([inst_func.__module__, inst_func.__name__]) logger = get_wrapped_logger( name=inst_funcname, log_level=logging.DEBUG) serverextensions.toggle_serverextension_python( 'jupyter_nbextensions_configurator', enabled=True, logger=logger, user=cls._install_user, sys_prefix=cls._install_sys_prefix)
def setup_class(cls): """Install things & setup a notebook server in a separate thread.""" cls.log = get_wrapped_logger(cls.__name__) cls._setup_patches() cls.pre_server_setup() try: started = Event() cls.notebook_thread = Thread(target=cls.start_server_thread, args=[started]) cls.notebook_thread.start() started.wait() cls.wait_until_alive() except Exception: for func in cls.removal_funcs: func() raise
def setup_class(cls): """Install things & setup a notebook server in a separate thread.""" cls.log = get_wrapped_logger(cls.__name__) cls._setup_patches() cls.pre_server_setup() try: started = Event() cls.notebook_thread = Thread( target=cls.start_server_thread, args=[started]) cls.notebook_thread.start() started.wait() cls.wait_until_alive() except Exception: for func in cls.removal_funcs: func() raise