当前位置: 首页>>代码示例>>Python>>正文


Python MarionetteTestCase.tearDown方法代码示例

本文整理汇总了Python中marionette.MarionetteTestCase.tearDown方法的典型用法代码示例。如果您正苦于以下问题:Python MarionetteTestCase.tearDown方法的具体用法?Python MarionetteTestCase.tearDown怎么用?Python MarionetteTestCase.tearDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marionette.MarionetteTestCase的用法示例。


在下文中一共展示了MarionetteTestCase.tearDown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
 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)
开发者ID:strikeX100,项目名称:gaia,代码行数:9,代码来源:gaia_test.py

示例2: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
    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)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:36,代码来源:test_refresh_firefox.py

示例3: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
    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)
开发者ID:kumar303,项目名称:gaia-ui-tests,代码行数:29,代码来源:gaia_test.py

示例4: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
    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)
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:10,代码来源:test_quit_restart.py

示例5: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
    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)
开发者ID:kilikkuo,项目名称:gecko-dev,代码行数:14,代码来源:base.py

示例6: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
    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)
开发者ID:alivesay,项目名称:gaia,代码行数:20,代码来源:gaia_test.py

示例7: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
    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)
开发者ID:klrmn,项目名称:gaia-ui-tests,代码行数:21,代码来源:gaia_test.py

示例8: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
    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)
开发者ID:pragmatictester,项目名称:gaia-ui-tests,代码行数:42,代码来源:gaia_test.py

示例9: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
    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)
开发者ID:IamAdiSri,项目名称:firefox-ui-tests,代码行数:26,代码来源:base.py

示例10: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
 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)
开发者ID:MekliCZ,项目名称:positron,代码行数:7,代码来源:test_elementState_chrome.py

示例11: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
 def tearDown(self):
     BrowserMobProxyTestCaseMixin.tearDown(self)
     MarionetteTestCase.tearDown(self)
开发者ID:lgarner,项目名称:mozilla-central,代码行数:5,代码来源:browsermob.py

示例12: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
 def tearDown(self):
     self.assertEqual(self.get_context(), self.marionette.CONTEXT_CHROME)
     MarionetteTestCase.tearDown(self)
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:5,代码来源:test_teardown_context_preserved.py

示例13: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
 def tearDown(self):
     # Code to execute after a test is being run.
     self.expiration_time = self.original_expiration_time
     MarionetteTestCase.tearDown(self)
开发者ID:LordJZ,项目名称:gecko-dev,代码行数:6,代码来源:test_touchcaret.py

示例14: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
 def tearDown(self):
     self.marionette.execute_script("window.wrappedJSObject.dispatchEvent(new Event('home'));")
     time.sleep(2)
     MarionetteTestCase.tearDown(self)
开发者ID:ypwalter,项目名称:MTBF-Driver,代码行数:6,代码来源:MtbfTestCase.py

示例15: tearDown

# 需要导入模块: from marionette import MarionetteTestCase [as 别名]
# 或者: from marionette.MarionetteTestCase import tearDown [as 别名]
 def tearDown(self):
     self.marionette.delete_all_cookies()
     MarionetteTestCase.tearDown(self)
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:5,代码来源:test_cookies.py


注:本文中的marionette.MarionetteTestCase.tearDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。