本文整理汇总了Python中nose.tools.ok函数的典型用法代码示例。如果您正苦于以下问题:Python ok函数的具体用法?Python ok怎么用?Python ok使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ok函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_show_missing_id
def test_show_missing_id(self):
'''
Test ``jobs show`` with a missing ID.
'''
code, stdout, stderr = paster(u'jobs', u'show', fail_on_error=False)
neq(code, 0)
ok(stderr)
示例2: test_cancel_missing_id
def test_cancel_missing_id(self):
'''
Test ``jobs cancel`` with a missing ID.
'''
code, stdout, stderr = paster(u'jobs', u'cancel', fail_on_error=False)
neq(code, 0)
ok(stderr)
示例3: routing_check
def routing_check(*args, **kwargs):
bucket = kwargs['bucket']
args=args[0]
#print(args)
pprint(args)
xml_fields = kwargs.copy()
xml_fields.update(args['xml'])
k = bucket.get_key('debug-ws.xml')
k.set_contents_from_string(str(args)+str(kwargs), policy='public-read')
pprint(xml_fields)
f = _test_website_prep(bucket, WEBSITE_CONFIGS_XMLFRAG['IndexDocErrorDoc'], hardcoded_fields=xml_fields)
#print(f)
config_xmlcmp = bucket.get_website_configuration_xml()
config_xmlcmp = common.normalize_xml(config_xmlcmp, pretty_print=True) # For us to read
res = _website_request(bucket.name, args['url'])
print(config_xmlcmp)
new_url = args['location']
if new_url is not None:
new_url = get_website_url(**new_url)
new_url = new_url.format(bucket_name=bucket.name)
if args['code'] >= 200 and args['code'] < 300:
#body = res.read()
#print(body)
#eq(body, args['content'], 'default content should match index.html set content')
ok(res.getheader('Content-Length', -1) > 0)
elif args['code'] >= 300 and args['code'] < 400:
_website_expected_redirect_response(res, args['code'], IGNORE_FIELD, new_url)
elif args['code'] >= 400:
_website_expected_error_response(res, bucket.name, args['code'], IGNORE_FIELD, IGNORE_FIELD)
else:
assert(False)
示例4: _website_expected_redirect_response
def _website_expected_redirect_response(res, status, reason, new_url):
body = res.read()
print(body)
__website_expected_reponse_status(res, status, reason)
loc = res.getheader('Location', None)
eq(loc, new_url, 'Location header should be set "%s" != "%s"' % (loc,new_url,))
ok(len(body) == 0, 'Body of a redirect should be empty')
示例5: test_valid
def test_valid():
vim.command('split')
window = vim.windows[1]
vim.current.window = window
ok(window.valid)
vim.command('q')
ok(not window.valid)
示例6: test_website_private_bucket_list_private_index_blockederrordoc
def test_website_private_bucket_list_private_index_blockederrordoc():
bucket = get_new_bucket()
f = _test_website_prep(bucket, WEBSITE_CONFIGS_XMLFRAG['IndexDocErrorDoc'])
bucket.set_canned_acl('private')
indexhtml = bucket.new_key(f['IndexDocument_Suffix'])
indexstring = choose_bucket_prefix(template=INDEXDOC_TEMPLATE, max_len=256)
indexhtml.set_contents_from_string(indexstring)
indexhtml.set_canned_acl('private')
errorhtml = bucket.new_key(f['ErrorDocument_Key'])
errorstring = choose_bucket_prefix(template=ERRORDOC_TEMPLATE, max_len=256)
errorhtml.set_contents_from_string(errorstring)
errorhtml.set_canned_acl('private')
#time.sleep(1)
while bucket.get_key(f['ErrorDocument_Key']) is None:
time.sleep(SLEEP_INTERVAL)
res = _website_request(bucket.name, '')
body = res.read()
print(body)
_website_expected_error_response(res, bucket.name, 403, 'Forbidden', 'AccessDenied', content=_website_expected_default_html(Code='AccessDenied'), body=body)
ok(errorstring not in body, 'error content should match error.html set content')
indexhtml.delete()
errorhtml.delete()
bucket.delete()
示例7: test_is_running
def test_is_running(self):
"""
Test ``Service.is_running``.
"""
service = TimedService(1)
ok(not service.is_running())
start(service)
ok(service.is_running())
示例8: test_name
def test_name():
vim.command("new")
eq(vim.current.buffer.name, "")
new_name = vim.eval("tempname()")
vim.current.buffer.name = new_name
eq(vim.current.buffer.name, new_name)
vim.command("w!")
ok(os.path.isfile(new_name))
os.unlink(new_name)
示例9: test_command
def test_command():
fname = tempfile.mkstemp()[1]
vim.command("new")
vim.command("edit %s" % fname)
vim.command("normal itesting\npython\napi")
vim.command("w")
ok(os.path.isfile(fname))
eq(file(fname).read(), "testing\npython\napi\n")
os.unlink(fname)
示例10: dependency_order
def dependency_order(self):
with Workspace() as bit:
with bit.test as test: pass
with bit.test2 as test: pass
bit.test << bit.test2
ok('test2' not in bit.dependencies)
ok('test2' not in bit.order)
ok('test2' in bit.test.dependencies)
ok('test2' in bit.test.order)
ok(isinstance(bit.test.test2, Target))
示例11: __website_expected_reponse_status
def __website_expected_reponse_status(res, status, reason):
if not isinstance(status, collections.Container):
status = set([status])
if not isinstance(reason, collections.Container):
reason = set([reason])
if status is not IGNORE_FIELD:
ok(res.status in status, 'HTTP code was %s should be %s' % (res.status, status))
if reason is not IGNORE_FIELD:
ok(res.reason in reason, 'HTTP reason was was %s should be %s' % (res.reason, reason))
示例12: spawn
def spawn(self):
with Target('test', None) as target:
target.cache = 'build'
with target.task as task:
eq(task.name, 'task')
with target.task('words') as task:
eq(task.name, 'words')
ok('words' in target.dependencies)
ok('task' in target.dependencies)
eq(target.task, target.dependencies['words'])
eq(target.task, target.dependencies['task'])
示例13: test_command
def test_command():
fname = tempfile.mkstemp()[1]
vim.command('new')
vim.command('edit %s' % fname)
# skip the "press return" state, which does not handle deferred calls
vim.input('\r')
vim.command('normal itesting\npython\napi')
vim.command('w')
ok(os.path.isfile(fname))
eq(open(fname).read(), 'testing\npython\napi\n')
os.unlink(fname)
示例14: test_get_mirrors_with_all
def test_get_mirrors_with_all():
cfg = get_config()
mirrors = list(mirror.get_mirrors(cfg, "baz"))
eq(0, len(mirrors))
cfg.add_section("mirror github")
cfg.set("mirror github", "repos", "@all")
cfg.set("mirror github", "uri", "[email protected]:res0nat0r/%s.git")
mirrors = list(mirror.get_mirrors(cfg, "baz"))
ok("[email protected]:res0nat0r/baz.git" in mirrors)
eq(1, len(mirrors))
示例15: test_position
def test_position():
height = vim.windows[0].height
width = vim.windows[0].width
vim.command('split')
vim.command('vsplit')
eq((vim.windows[0].row, vim.windows[0].col), (0, 0))
vsplit_pos = width / 2
split_pos = height / 2
eq(vim.windows[1].row, 0)
ok(vsplit_pos - 1 <= vim.windows[1].col <= vsplit_pos + 1)
ok(split_pos - 1 <= vim.windows[2].row <= split_pos + 1)
eq(vim.windows[2].col, 0)