def tearDown(self): # Force yet another restart with a clean profile to disconnect from the # profile and environment changes we've made, to leave a more or less # blank slate for the next person. self.marionette.restart(clean=True, in_app=False) self.setUpScriptData() # Super MarionetteTestCase.tearDown(self) # Some helpers to deal with removing a load of files import errno, stat def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777 func(path) else: raise if self.desktop_backup_path: shutil.rmtree(self.desktop_backup_path, ignore_errors=False, onerror=handleRemoveReadonly) if self.reset_profile_path: # Remove ourselves from profiles.ini profileLeafName = os.path.basename(os.path.normpath(self.reset_profile_path)) self.runCode(""" let [salt, name] = arguments[0].split("."); let profile = global.profSvc.getProfileByName(name); profile.remove(false) global.profSvc.flush(); """, script_args=[profileLeafName]) # And delete all the files. shutil.rmtree(self.reset_profile_path, ignore_errors=False, onerror=handleRemoveReadonly)
def tearDown(self): if any(sys.exc_info()): # test has failed, gather debug test_class, test_name = self.marionette.test_name.split()[-1].split('.') xml_output = self.testvars.get('xml_output', None) debug_path = os.path.join(xml_output and os.path.dirname(xml_output) or 'debug', test_class) if not os.path.exists(debug_path): os.makedirs(debug_path) # screenshot with open(os.path.join(debug_path, '%s_screenshot.png' % test_name), 'w') as f: # TODO: Bug 818287 - Screenshots include data URL prefix screenshot = self.marionette.screenshot()[22:] f.write(base64.decodestring(screenshot)) # page source with open(os.path.join(debug_path, '%s_source.txt' % test_name), 'w') as f: f.write(self.marionette.page_source.encode('utf-8')) # settings with open(os.path.join(debug_path, '%s_settings.json' % test_name), 'w') as f: f.write(json.dumps(self.data_layer.all_settings)) self.lockscreen = None self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self): self.marionette.switch_to_frame() if self.device.is_desktop_b2g and self.device.storage_path: shutil.rmtree(self.device.storage_path, ignore_errors=True) self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self): self.marionette.switch_to_frame() if self.device.is_desktop_b2g and self.device.storage_path: shutil.rmtree(self.device.storage_path, ignore_errors=True) self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self): # Ensure to restart a session if none exist for clean-up if not self.marionette.session: self.marionette.start_session() self.marionette.clear_pref("browser.startup.page") MarionetteTestCase.tearDown(self)
def tearDown(self): # Ensure to restart a session if none exist for clean-up if not self.marionette.session: self.marionette.start_session() self.marionette.clear_pref("browser.startup.page") MarionetteTestCase.tearDown(self)
def tearDown(self, *args, **kwargs): self.marionette.set_context('chrome') try: self.prefs.restore_all_prefs() # This code should be run after all other tearDown code # so that in case of a failure, further tests will not run # in a state that is more inconsistent than necessary. self._check_and_fix_leaked_handles() finally: MarionetteTestCase.tearDown(self, *args, **kwargs)
def tearDown(self, *args, **kwargs): self.marionette.set_context('chrome') try: self.prefs.restore_all_prefs() # This code should be run after all other tearDown code # so that in case of a failure, further tests will not run # in a state that is more inconsistent than necessary. self._check_and_fix_leaked_handles() finally: MarionetteTestCase.tearDown(self, *args, **kwargs)
def tearDown(self): if any(sys.exc_info()): # test has failed, gather debug test_class, test_name = self.marionette.test_name.split( )[-1].split('.') xml_output = self.testvars.get('xml_output', None) debug_path = os.path.join( xml_output and os.path.dirname(xml_output) or 'debug', test_class) if not os.path.exists(debug_path): os.makedirs(debug_path) # screenshot try: with open( os.path.join(debug_path, '%s_screenshot.png' % test_name), 'w') as f: # TODO: Bug 818287 - Screenshots include data URL prefix screenshot = self.marionette.screenshot()[22:] f.write(base64.decodestring(screenshot)) except: traceback.print_exc() # page source try: with open( os.path.join(debug_path, '%s_source.txt' % test_name), 'w') as f: f.write(self.marionette.page_source.encode('utf-8')) except: traceback.print_exc() # settings # Switch to top frame in case we are in a 3rd party app # There is no more debug gathering is not specific to the app self.marionette.switch_to_frame() try: with open( os.path.join(debug_path, '%s_settings.json' % test_name), 'w') as f: f.write(json.dumps(self.data_layer.all_settings)) except: traceback.print_exc() self.lockscreen = None self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self): if any(sys.exc_info()): # test has failed, gather debug test_name = self.marionette.test_name.split()[-1] debug_path = os.path.join('debug', *test_name.split('.')) if not os.path.exists(debug_path): os.makedirs(debug_path) # screenshot with open(os.path.join(debug_path, 'screenshot.png'), 'w') as f: # TODO: Bug 818287 - Screenshots include data URL prefix screenshot = self.marionette.screenshot()[22:] f.write(base64.decodestring(screenshot)) self.lockscreen = None self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self): if any(sys.exc_info()): # test has failed, gather debug test_class, test_name = self.marionette.test_name.split()[-1].split(".") xml_output = self.testvars.get("xml_output", None) debug_path = os.path.join(xml_output and os.path.dirname(xml_output) or "debug", test_class) if not os.path.exists(debug_path): os.makedirs(debug_path) # screenshot with open(os.path.join(debug_path, "%s_screenshot.png" % test_name), "w") as f: # TODO: Bug 818287 - Screenshots include data URL prefix screenshot = self.marionette.screenshot()[22:] f.write(base64.decodestring(screenshot)) self.lockscreen = None self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self): # Force yet another restart with a clean profile to disconnect from the # profile and environment changes we've made, to leave a more or less # blank slate for the next person. self.marionette.restart(clean=True, in_app=False) self.setUpScriptData() # Super MarionetteTestCase.tearDown(self) # Some helpers to deal with removing a load of files import errno, stat def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777 func(path) else: raise if self.desktop_backup_path: shutil.rmtree(self.desktop_backup_path, ignore_errors=False, onerror=handleRemoveReadonly) if self.reset_profile_path: # Remove ourselves from profiles.ini profileLeafName = os.path.basename( os.path.normpath(self.reset_profile_path)) self.runCode(""" let [salt, name] = arguments[0].split("."); let profile = global.profSvc.getProfileByName(name); profile.remove(false) global.profSvc.flush(); """, script_args=[profileLeafName]) # And delete all the files. shutil.rmtree(self.reset_profile_path, ignore_errors=False, onerror=handleRemoveReadonly)
def tearDown(self): if any(sys.exc_info()): # test has failed, gather debug test_class, test_name = self.marionette.test_name.split()[-1].split('.') xml_output = self.testvars.get('xml_output', None) debug_path = os.path.join(xml_output and os.path.dirname(xml_output) or 'debug', test_class) if not os.path.exists(debug_path): os.makedirs(debug_path) # screenshot try: with open(os.path.join(debug_path, '%s_screenshot.png' % test_name), 'w') as f: # TODO: Bug 818287 - Screenshots include data URL prefix screenshot = self.marionette.screenshot()[22:] f.write(base64.decodestring(screenshot)) except: traceback.print_exc() # page source try: with open(os.path.join(debug_path, '%s_source.txt' % test_name), 'w') as f: f.write(self.marionette.page_source.encode('utf-8')) except: traceback.print_exc() # settings # Switch to top frame in case we are in a 3rd party app # There is no more debug gathering is not specific to the app self.marionette.switch_to_frame() try: with open(os.path.join(debug_path, '%s_settings.json' % test_name), 'w') as f: f.write(json.dumps(self.data_layer.all_settings)) except: traceback.print_exc() self.lockscreen = None self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self, *args, **kwargs): self.marionette.set_context('chrome') try: # Marionette needs an existent window to be selected. Take the first # browser window which has at least one open tab # TODO: We might have to make this more error prone in case the # original window has been closed. self.browser.tabbar.tabs[0].switch_to() self.prefs.restore_all_prefs() # This assertion should be run after all other tearDown code # so that in case of a failure, further tests will not run # in a state that is more inconsistent than necessary. win_count = len(self.marionette.window_handles) self.assertEqual(win_count, self._start_handle_count, "A test must not leak window handles. " "This test started the browser with %s open " "top level browsing contexts, but ended with %s." % (self._start_handle_count, win_count)) finally: MarionetteTestCase.tearDown(self, *args, **kwargs)
def tearDown(self): if any(sys.exc_info()): # test has failed, gather debug test_class, test_name = self.marionette.test_name.split( )[-1].split('.') xml_output = self.testvars.get('xml_output', None) debug_path = os.path.join( xml_output and os.path.dirname(xml_output) or 'debug', test_class) if not os.path.exists(debug_path): os.makedirs(debug_path) # screenshot with open( os.path.join(debug_path, '%s_screenshot.png' % test_name), 'w') as f: # TODO: Bug 818287 - Screenshots include data URL prefix screenshot = self.marionette.screenshot()[22:] f.write(base64.decodestring(screenshot)) self.lockscreen = None self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self, *args, **kwargs): self.marionette.set_context('chrome') try: # Marionette needs an existent window to be selected. Take the first # browser window which has at least one open tab # TODO: We might have to make this more error prone in case the # original window has been closed. self.browser.focus() self.browser.tabbar.tabs[0].switch_to() self.prefs.restore_all_prefs() # This assertion should be run after all other tearDown code # so that in case of a failure, further tests will not run # in a state that is more inconsistent than necessary. win_count = len(self.marionette.window_handles) self.assertEqual(win_count, self._start_handle_count, "A test must not leak window handles. " "This test started the browser with %s open " "top level browsing contexts, but ended with %s." % (self._start_handle_count, win_count)) finally: MarionetteTestCase.tearDown(self, *args, **kwargs)
def tearDown(self): self.assertEqual(self.get_context(), self.marionette.CONTEXT_CHROME) MarionetteTestCase.tearDown(self)
def tearDown(self): self.marionette.delete_all_cookies() MarionetteTestCase.tearDown(self)
def tearDown(self): #ensure that we close the window, regardless of pass/failure self.close_new_window() MarionetteTestCase.tearDown(self)
def tearDown(self): BrowserMobProxyTestCaseMixin.tearDown(self) MarionetteTestCase.tearDown(self)
def tearDown(self): self.marionette.reset_timeouts() MarionetteTestCase.tearDown(self)
def tearDown(self): # Code to execute after a test is being run. self.expiration_time = self.original_expiration_time MarionetteTestCase.tearDown(self)
def tearDown(self): self.marionette.reset_timeouts() MarionetteTestCase.tearDown(self)
def tearDown(self): self.lockscreen = None self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self, *args, **kwargs): self.lib.client = None MarionetteTestCase.tearDown(self, *args, **kwargs)
def tearDown(self): self.assertEqual(self.get_context(), self.marionette.CONTEXT_CHROME) MarionetteTestCase.tearDown(self)
def tearDown(self): self.assertNotEqual(self.win, self.marionette.current_window_handle) self.marionette.execute_script("window.close();") self.marionette.switch_to_window(self.win) MarionetteTestCase.tearDown(self)
def tearDown(self): self.loop_test_servers.shutdown() MarionetteTestCase.tearDown(self)
def tearDown(self): MarionetteTestCase.tearDown(self)
def tearDown(self): self.logger.debug("tearing down!") MarionetteTestCase.tearDown(self) self.logger.debug("done tearing down!")
def tearDown(self): #ensure that we close the window, regardless of pass/failure self.close_new_window() MarionetteTestCase.tearDown(self)
def tearDown(self): if self.is_mobile: self.marionette.set_orientation(default_orientation) self.assertEqual(self.marionette.orientation, default_orientation, "invalid state") MarionetteTestCase.tearDown(self)
def tearDown(self): self.marionette.delete_all_cookies() MarionetteTestCase.tearDown(self)
def tearDown(self): # Code to execute after a test is being run. self.expiration_time = self.original_expiration_time MarionetteTestCase.tearDown(self)
def tearDown(self): self.loop_test_servers.shutdown() MarionetteTestCase.tearDown(self)
def tearDown(self): try: self.marionette.delete_session() except: pass MarionetteTestCase.tearDown(self)
def tearDown(self): if self.is_mobile: self.marionette.set_orientation(default_orientation) self.assertEqual(self.marionette.orientation, default_orientation, "invalid state") MarionetteTestCase.tearDown(self)
def tearDown(self): self.assertNotEqual(self.win, self.marionette.current_window_handle) self.marionette.execute_script("window.close();") self.marionette.switch_to_window(self.win) MarionetteTestCase.tearDown(self)
def tearDown(self): self.marionette.execute_script("window.wrappedJSObject.dispatchEvent(new Event('home'));") time.sleep(2) MarionetteTestCase.tearDown(self)
def tearDown(self): self.lockscreen = None self.apps = None self.data_layer = None MarionetteTestCase.tearDown(self)
def tearDown(self): self.logger.debug("tearing down!") MarionetteTestCase.tearDown(self) self.logger.debug("done tearing down!")
def tearDown(self): self.marionette.execute_script("window.close();") self.marionette.switch_to_window(self.win) MarionetteTestCase.tearDown(self)
def tearDown(self): try: self.marionette.delete_session() except: pass MarionetteTestCase.tearDown(self)