本文整理汇总了Python中plainbox.impl.session.SessionState.get_estimated_duration方法的典型用法代码示例。如果您正苦于以下问题:Python SessionState.get_estimated_duration方法的具体用法?Python SessionState.get_estimated_duration怎么用?Python SessionState.get_estimated_duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plainbox.impl.session.SessionState
的用法示例。
在下文中一共展示了SessionState.get_estimated_duration方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_estimated_duration_manual_unknown
# 需要导入模块: from plainbox.impl.session import SessionState [as 别名]
# 或者: from plainbox.impl.session.SessionState import get_estimated_duration [as 别名]
def test_get_estimated_duration_manual_unknown(self):
four_seconds = make_job("four_seconds", plugin="shell",
command="fibble",
estimated_duration=4.0)
no_estimated_duration = make_job("no_estimated_duration",
plugin="user-verify",
command="bibble")
session = SessionState([four_seconds, no_estimated_duration])
session.update_desired_job_list([four_seconds, no_estimated_duration])
self.assertEqual(session.get_estimated_duration(), (4.0, None))
示例2: test_get_estimated_duration_automated_unknown
# 需要导入模块: from plainbox.impl.session import SessionState [as 别名]
# 或者: from plainbox.impl.session.SessionState import get_estimated_duration [as 别名]
def test_get_estimated_duration_automated_unknown(self):
three_seconds = make_job("three_seconds", plugin="shell",
command="frob",
estimated_duration=3.0)
no_estimated_duration = make_job("no_estimated_duration",
plugin="shell",
command="borf")
session = SessionState([three_seconds, no_estimated_duration])
session.update_desired_job_list([three_seconds, no_estimated_duration])
self.assertEqual(session.get_estimated_duration(), (None, 0.0))
示例3: test_get_estimated_duration_manual
# 需要导入模块: from plainbox.impl.session import SessionState [as 别名]
# 或者: from plainbox.impl.session.SessionState import get_estimated_duration [as 别名]
def test_get_estimated_duration_manual(self):
two_seconds = make_job("two_seconds", plugin="manual",
command="farboo",
estimated_duration=2.0)
shell_job = make_job("shell_job", plugin="shell",
command="boofar",
estimated_duration=0.6)
session = SessionState([two_seconds, shell_job])
session.update_desired_job_list([two_seconds, shell_job])
self.assertEqual(session.get_estimated_duration(), (0.6, 32.0))
示例4: test_get_estimated_duration_auto
# 需要导入模块: from plainbox.impl.session import SessionState [as 别名]
# 或者: from plainbox.impl.session.SessionState import get_estimated_duration [as 别名]
def test_get_estimated_duration_auto(self):
# Define jobs with an estimated duration
one_second = make_job("one_second", plugin="shell",
command="foobar",
estimated_duration=1.0)
half_second = make_job("half_second", plugin="shell",
command="barfoo",
estimated_duration=0.5)
session = SessionState([one_second, half_second])
session.update_desired_job_list([one_second, half_second])
self.assertEqual(session.get_estimated_duration(), (1.5, 0.0))
示例5: AnalyzeInvocation
# 需要导入模块: from plainbox.impl.session import SessionState [as 别名]
# 或者: from plainbox.impl.session.SessionState import get_estimated_duration [as 别名]
#.........这里部分代码省略.........
self.session.update_job_result(job, result)
new_desired_job_list = self._get_matching_job_list(
self.ns, self.session.job_list)
new_problem_list = self.session.update_desired_job_list(
new_desired_job_list)
if new_problem_list:
print(_("Problem list"), new_problem_list)
self.problem_list.extend(new_problem_list)
def _print_general_stats(self):
print(_("[General Statistics]").center(80, '='))
print(_("Known jobs: {}").format(len(self.job_list)))
print(_("Selected jobs: {}").format(len(self.desired_job_list)))
def _print_dependency_report(self):
print(_("[Dependency Report]").center(80, '='))
if self.problem_list:
for problem in self.problem_list:
print(" * {}".format(problem))
else:
print(_("Selected jobs have no dependency problems"))
def _print_interactivity_report(self):
print(_("[Interactivity Report]").center(80, '='))
if not self.session.run_list:
return
max_job_len = max(len(job.id) for job in self.session.run_list)
fmt = "{{job:{}}} : {{interactive:11}} : {{duration}}".format(
max_job_len)
for job in self.session.run_list:
print(
fmt.format(
job=job.id,
interactive=(
_("automatic") if job.automated else _("interactive")),
duration=(
# TODO: use python-babel to format localized timedelta
# in 14.04+ as 12.04 babel API is too limited
timedelta(seconds=job.estimated_duration)
if job.estimated_duration is not None
else _("unknown"))
)
)
def _print_estimated_duration_report(self):
print(_("[Estimated Duration Report]").center(80, '='))
print(_("Estimated test duration:"))
automated, manual = self.session.get_estimated_duration()
print(" " + _("automated tests: {}").format(
timedelta(seconds=automated) if automated is not None
else _("cannot estimate")))
print(" " + _("manual tests: {}").format(
timedelta(seconds=manual) if manual is not None
else _("cannot estimate")))
print(" " + _("total: {}").format(
timedelta(seconds=manual + automated)
if manual is not None and automated is not None
else _("cannot estimate")))
def _print_validation_report(self, only_errors):
print(_("[Validation Report]").center(80, '='))
if not self.session.run_list:
return
max_job_len = max(len(job.id) for job in self.session.run_list)
fmt = "{{job:{}}} : {{problem}}".format(max_job_len)
problem = None
for job in self.session.run_list:
try:
job.validate()
except ValueError as exc:
problem = str(exc)
else:
if only_errors:
continue
problem = ""
print(fmt.format(job=job.id, problem=problem))
if problem:
print(_("Job defined in {}").format(job.origin))
if only_errors and problem is None:
print(_("No problems found"))
def _print_requirement_report(self):
print(_("[Requirement Report]").center(80, '='))
if not self.session.run_list:
return
requirements = set()
for job in self.session.run_list:
if job.requires:
resource_program = job.get_resource_program()
if 'package' in resource_program.required_resources:
for packages in [
resource.text for resource in
resource_program.expression_list
if resource.resource_id == 'package']:
node = ast.parse(packages)
visitor = RequirementNodeVisitor()
visitor.visit(node)
requirements.add((' | ').join(visitor.packages_seen))
if requirements:
print(',\n'.join(sorted(requirements)))