本文整理汇总了Python中marionette_driver.marionette.Marionette.delete_session方法的典型用法代码示例。如果您正苦于以下问题:Python Marionette.delete_session方法的具体用法?Python Marionette.delete_session怎么用?Python Marionette.delete_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette_driver.marionette.Marionette
的用法示例。
在下文中一共展示了Marionette.delete_session方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CommonTestCase
# 需要导入模块: from marionette_driver.marionette import Marionette [as 别名]
# 或者: from marionette_driver.marionette.Marionette import delete_session [as 别名]
#.........这里部分代码省略.........
else:
self.tearDown()
except KeyboardInterrupt:
raise
except _ExpectedFailure as e:
expected_failure(result, e.exc_info)
except:
self._enter_pm()
result.addError(self, sys.exc_info())
success = False
# Here we could handle doCleanups() instead of calling cleanTest directly
self.cleanTest()
if success:
result.addSuccess(self)
finally:
result.stopTest(self)
if orig_result is None:
stopTestRun = getattr(result, "stopTestRun", None)
if stopTestRun is not None:
stopTestRun()
@classmethod
def match(cls, filename):
"""
Determines if the specified filename should be handled by this
test class; this is done by looking for a match for the filename
using cls.match_re.
"""
if not cls.match_re:
return False
m = cls.match_re.match(filename)
return m is not None
@classmethod
def add_tests_to_suite(cls, mod_name, filepath, suite, testloader, testvars):
"""
Adds all the tests in the specified file to the specified suite.
"""
raise NotImplementedError
@property
def test_name(self):
if hasattr(self, "jsFile"):
return os.path.basename(self.jsFile)
else:
return "%s.py %s.%s" % (self.__class__.__module__, self.__class__.__name__, self._testMethodName)
def id(self):
# TBPL starring requires that the "test name" field of a failure message
# not differ over time. The test name to be used is passed to
# mozlog via the test id, so this is overriden to maintain
# consistency.
return self.test_name
def setUp(self):
# Convert the marionette weakref to an object, just for the
# duration of the test; this is deleted in tearDown() to prevent
# a persistent circular reference which in turn would prevent
# proper garbage collection.
self.start_time = time.time()
self.pingServer = PingServer()
self.pingServer.start()
self.marionette = Marionette(bin=self.binary, profile=self.profile)
if self.marionette.session is None:
self.marionette.start_session()
if self.marionette.timeout is not None:
self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, self.marionette.timeout)
self.marionette.timeouts(self.marionette.TIMEOUT_SCRIPT, self.marionette.timeout)
self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, self.marionette.timeout)
else:
self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, 30000)
def tearDown(self):
self.marionette.cleanup()
self.pingServer.stop()
def cleanTest(self):
self._deleteSession()
def _deleteSession(self):
if hasattr(self, "start_time"):
self.duration = time.time() - self.start_time
if hasattr(self.marionette, "session"):
if self.marionette.session is not None:
try:
self.loglines.extend(self.marionette.get_logs())
except Exception, inst:
self.loglines = [["Error getting log: %s" % inst]]
try:
self.marionette.delete_session()
except (socket.error, MarionetteException, IOError):
# Gecko has crashed?
self.marionette.session = None
try:
self.marionette.client.close()
except socket.error:
pass
self.marionette = None
示例2: GCli
# 需要导入模块: from marionette_driver.marionette import Marionette [as 别名]
# 或者: from marionette_driver.marionette.Marionette import delete_session [as 别名]
#.........这里部分代码省略.........
'unlock': {
'function': self.unlock,
'help': 'Unlock screen'},
'volume': {
'function': self.volume,
'args': [
{'name': 'direction',
'choices': ['down', 'up'],
'help': 'Direction to change the volume'}],
'help': 'Change the volume'},
'wake': {
'function': self.wake,
'help': 'Wake from sleep mode'}}
self.parser = argparse.ArgumentParser()
self.add_options(self.parser)
self.add_commands(self.parser)
def run(self, args=sys.argv[1:]):
args = self.parser.parse_args()
host, port = args.address.split(':')
self.marionette = Marionette(host=host, port=int(port))
self.marionette.start_session()
self.apps = gaiatest.GaiaApps(self.marionette)
self.data_layer = gaiatest.GaiaData(self.marionette)
self.device = gaiatest.GaiaDevice(self.marionette)
ret = args.func(args)
if ret is None:
ret = 0
self.marionette.delete_session()
sys.exit(ret)
def add_options(self, parser):
parser.add_argument(
'--address',
default='localhost:2828',
help='Address (host:port) of running Gecko instance to connect to '
'(default: %(default)s)')
def add_commands(self, parser):
subparsers = parser.add_subparsers(
title='Commands', metavar='<command>')
for (name, props) in sorted(self.commands.iteritems()):
subparser = subparsers.add_parser(name, help=props['help'])
if props.get('args'):
for arg in props['args']:
kwargs = {k: v for k, v in arg.items() if k is not 'name'}
subparser.add_argument(arg['name'], **kwargs)
subparser.set_defaults(func=props['function'])
def connect_to_wifi(self, args):
network = {
'ssid': args.ssid,
'keyManagement': args.security or 'NONE'}
if args.security == 'WEP':
network['wep'] = args.password
elif args.security == 'WPA-PSK':
network['psk'] = args.password
self.data_layer.connect_to_wifi(network)
def disable_wifi(self, args):