• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python spec.ok_函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中spec.ok_函数的典型用法代码示例。如果您正苦于以下问题:Python ok_函数的具体用法?Python ok_怎么用?Python ok_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: file_like_objects

 def file_like_objects(self):
     fd = BytesIO()
     fd.write(b"yup\n")
     result = self.c.put(local=fd, remote=self.remote)
     eq_(open(self.remote).read(), "yup\n")
     eq_(result.remote, self.remote)
     ok_(result.local is fd)
开发者ID:bossjones,项目名称:fabric,代码行数:7,代码来源:transfer.py


示例2: handles_invalid_kwargs_like_any_other_function

 def handles_invalid_kwargs_like_any_other_function(self):
     try:
         self._run(_, nope_noway_nohow='as if')
     except TypeError as e:
         ok_('got an unexpected keyword argument' in str(e))
     else:
         assert False, "Invalid run() kwarg didn't raise TypeError"
开发者ID:gtback,项目名称:invoke,代码行数:7,代码来源:runners.py


示例3: exited_is_None

 def exited_is_None(self):
     try:
         self._watcher_error()
     except Failure as e:
         exited = e.result.exited
         err = "Expected None, got {0!r}".format(exited)
         ok_(exited is None, err)
开发者ID:gtback,项目名称:invoke,代码行数:7,代码来源:runners.py


示例4: stringrep_notes_exit_status

 def stringrep_notes_exit_status(self):
     try:
         self._regular_error()
     except Failure as e:
         ok_("exited with status 1" in str(e.result))
     else:
         assert False, "Did not raise Failure!"
开发者ID:gtback,项目名称:invoke,代码行数:7,代码来源:runners.py


示例5: exited_is_integer

 def exited_is_integer(self):
     try:
         self._regular_error()
     except Failure as e:
         ok_(isinstance(e.result.exited, int))
     else:
         assert False, "Did not raise Failure!"
开发者ID:gtback,项目名称:invoke,代码行数:7,代码来源:runners.py


示例6: preserves_basic_members

 def preserves_basic_members(self):
     c1 = Config(
         defaults={'key': 'default'},
         overrides={'key': 'override'},
         system_prefix='global',
         user_prefix='user',
         project_home='project',
         runtime_path='runtime.yaml',
     )
     c2 = c1.clone()
     # NOTE: expecting identical defaults also implicitly tests that
     # clone() passes in defaults= instead of doing an empty init +
     # copy. (When that is not the case, we end up with
     # global_defaults() being rerun and re-added to _defaults...)
     eq_(c2._defaults, c1._defaults)
     ok_(c2._defaults is not c1._defaults)
     eq_(c2._overrides, c1._overrides)
     ok_(c2._overrides is not c1._overrides)
     eq_(c2._system_prefix, c1._system_prefix)
     eq_(c2._user_prefix, c1._user_prefix)
     eq_(c2._project_home, c1._project_home)
     eq_(c2.prefix, c1.prefix)
     eq_(c2.file_prefix, c1.file_prefix)
     eq_(c2.env_prefix, c1.env_prefix)
     eq_(c2._runtime_path, c1._runtime_path)
开发者ID:brutus,项目名称:invoke,代码行数:25,代码来源:config.py


示例7: modifications_on_clone_do_not_alter_original

 def modifications_on_clone_do_not_alter_original(self):
     # Setup
     orig = Call(
         self.task,
         called_as='foo',
         args=[1, 2, 3],
         kwargs={'key': 'val'}
     )
     context = Context()
     context['setting'] = 'value'
     orig.context = context
     # Clone & tweak
     clone = orig.clone()
     newtask = Task(Mock(__name__='meh'))
     clone.task = newtask
     clone.called_as = 'notfoo'
     clone.args[0] = 7
     clone.kwargs['key'] = 'notval'
     clone.context['setting'] = 'notvalue'
     # Compare
     ok_(clone.task is not orig.task)
     eq_(orig.called_as, 'foo')
     eq_(clone.called_as, 'notfoo')
     eq_(orig.args, [1, 2, 3])
     eq_(clone.args, [7, 2, 3])
     eq_(orig.kwargs['key'], 'val')
     eq_(clone.kwargs['key'], 'notval')
     eq_(orig.context['setting'], 'value')
     eq_(clone.context['setting'], 'notvalue')
开发者ID:bollwyvl,项目名称:invoke,代码行数:29,代码来源:tasks.py


示例8: can_be_pickled

 def can_be_pickled(self):
     c = Context()
     c.foo = {'bar': {'biz': ['baz', 'buzz']}}
     c2 = pickle.loads(pickle.dumps(c))
     eq_(c, c2)
     ok_(c is not c2)
     ok_(c.foo.bar.biz is not c2.foo.bar.biz)
开发者ID:yws,项目名称:invoke,代码行数:7,代码来源:context.py


示例9: can_clone_into_a_subclass

 def can_clone_into_a_subclass(self):
     orig = Call(self.task)
     class MyCall(Call):
         pass
     clone = orig.clone(into=MyCall)
     eq_(clone, orig)
     ok_(isinstance(clone, MyCall))
开发者ID:brutus,项目名称:invoke,代码行数:7,代码来源:tasks.py


示例10: base_case

 def base_case(self):
     queue = Queue()
     t = EHThread(target=self.worker, args=[queue])
     t.start()
     t.join()
     eq_(queue.get(block=False), 7)
     ok_(queue.empty())
开发者ID:brutus,项目名称:invoke,代码行数:7,代码来源:concurrency.py


示例11: prefixes_command_with_sudo

 def prefixes_command_with_sudo(self, Local):
     runner = Local.return_value
     Context().sudo('whoami')
     # NOTE: implicitly tests default sudo.prompt conf value
     cmd = "sudo -S -p '[sudo] password: ' whoami"
     ok_(runner.run.called, "sudo() never called runner.run()!")
     eq_(runner.run.call_args[0][0], cmd)
开发者ID:yws,项目名称:invoke,代码行数:7,代码来源:context.py


示例12: comparison_looks_at_merged_config

 def comparison_looks_at_merged_config(self):
     c1 = Config(defaults={'foo': {'bar': 'biz'}})
     # Empty defaults to suppress global_defaults
     c2 = Config(defaults={}, overrides={'foo': {'bar': 'biz'}})
     ok_(c1 is not c2)
     ok_(c1._defaults != c2._defaults)
     eq_(c1, c2)
开发者ID:gtback,项目名称:invoke,代码行数:7,代码来源:config.py


示例13: is_exception_when_WatcherError_raised_internally

 def is_exception_when_WatcherError_raised_internally(self):
     try:
         self._watcher_error()
     except Failure as e:
         ok_(isinstance(e.reason, WatcherError))
     else:
         assert False, "Failed to raise Failure!"
开发者ID:gtback,项目名称:invoke,代码行数:7,代码来源:runners.py


示例14: optional_prevents_bool_defaults_from_affecting_kind

 def optional_prevents_bool_defaults_from_affecting_kind(self):
     # Re #416. See notes in the function under test for rationale.
     @task(optional=['myarg'])
     def mytask(c, myarg=False):
         pass
     arg = mytask.get_arguments()[0]
     ok_(arg.kind is str) # not bool!
开发者ID:brutus,项目名称:invoke,代码行数:7,代码来源:tasks.py


示例15: dict_value_merges_are_not_references

 def dict_value_merges_are_not_references(self):
     core = {}
     coll = {'foo': {'bar': {'biz': 'coll value'}}}
     proj = {'foo': {'bar': {'biz': 'proj value'}}}
     # Initial merge - when bug present, this sets core['foo'] to the entire
     # 'foo' dict in 'proj' as a reference - meaning it 'links' back to the
     # 'proj' dict whenever other things are merged into it
     merge_dicts(core, proj)
     eq_(core, {'foo': {'bar': {'biz': 'proj value'}}})
     eq_(proj['foo']['bar']['biz'], 'proj value')
     # Identity tests can also prove the bug early
     ok_(core['foo'] is not proj['foo'], "Core foo is literally proj foo!")
     # Subsequent merge - just overwrites leaf values this time (thus no
     # real change, but this is what real config merge code does, so why
     # not)
     merge_dicts(core, proj)
     eq_(core, {'foo': {'bar': {'biz': 'proj value'}}})
     eq_(proj['foo']['bar']['biz'], 'proj value')
     # The problem merge - when bug present, core['foo'] references 'foo'
     # inside 'proj', so this ends up tweaking "core" but it actually
     # affects "proj" as well!
     merge_dicts(core, coll)
     # Expect that the core dict got the update from 'coll'...
     eq_(core, {'foo': {'bar': {'biz': 'coll value'}}})
     # BUT that 'proj' remains UNTOUCHED
     eq_(proj['foo']['bar']['biz'], 'proj value')
开发者ID:gtback,项目名称:invoke,代码行数:26,代码来源:merge_dicts.py


示例16: returns_run_result

 def returns_run_result(self, Local):
     runner = Local.return_value
     expected = runner.run.return_value
     result = Context().sudo('whoami')
     ok_(
         result is expected,
         "sudo() did not return run()'s return value!",
     )
开发者ID:yws,项目名称:invoke,代码行数:8,代码来源:context.py


示例17: hide_unknown_vals_mention_value_given_in_error

 def hide_unknown_vals_mention_value_given_in_error(self):
     value = "penguinmints"
     try:
         run("command", hide=value)
     except ValueError, e:
         msg = "Error from run(hide=xxx) did not tell user what the bad value was!"
         msg += "\nException msg: %s" % e
         ok_(value in str(e), msg)
开发者ID:alex,项目名称:invoke,代码行数:8,代码来源:run.py


示例18: returns_deep_copy_of_given_dict

 def returns_deep_copy_of_given_dict(self):
     # NOTE: not actual deepcopy...
     source = {'foo': {'bar': {'biz': 'baz'}}}
     copy = copy_dict(source)
     eq_(copy['foo']['bar'], source['foo']['bar'])
     ok_(copy['foo']['bar'] is not source['foo']['bar'])
     copy['foo']['bar']['biz'] = 'notbaz'
     eq_(source['foo']['bar']['biz'], 'baz')
开发者ID:gtback,项目名称:invoke,代码行数:8,代码来源:merge_dicts.py


示例19: kwargs

 def kwargs(self):
     k = {'foo': 'bar'}
     self.executor.execute(('task1', k))
     args = self.task1.body.call_args[0]
     kwargs = self.task1.body.call_args[1]
     ok_(isinstance(args[0], Context))
     eq_(len(args), 1)
     eq_(kwargs['foo'], 'bar')
开发者ID:bollwyvl,项目名称:invoke,代码行数:8,代码来源:executor.py


示例20: task_has_no_help_shows_per_task_help

 def task_has_no_help_shows_per_task_help(self):
     task1 = Context('mytask')
     init = Context(args=[Argument('help', optional=True)])
     parser = Parser(initial=init, contexts=[task1])
     result = parser.parse_argv(['mytask', '--help'])
     eq_(len(result), 2)
     eq_(result[0].args.help.value, 'mytask')
     ok_('help' not in result[1].args)
开发者ID:jr-minnaar,项目名称:invoke,代码行数:8,代码来源:parser.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python spec.skip函数代码示例发布时间:2022-05-27
下一篇:
Python spec.eq_函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap