本文整理汇总了Python中tg._compat.u_函数的典型用法代码示例。如果您正苦于以下问题:Python u_函数的具体用法?Python u_怎么用?Python u_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了u_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_unicode
def test_unicode():
"""url() can handle unicode parameters"""
create_request("/")
unicodestring = u_('àèìòù')
eq_(url('/', params=dict(x=unicodestring)),
'/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9'
)
开发者ID:Shamefox,项目名称:tg2,代码行数:7,代码来源:test_controllers.py
示例2: test_unicode
def test_unicode():
"""url() can handle unicode parameters"""
with test_context(None, '/'):
unicodestring = u_('àèìòù')
eq_(url('/', params=dict(x=unicodestring)),
'/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9'
)
开发者ID:984958198,项目名称:tg2,代码行数:7,代码来源:test_controllers.py
示例3: test_custom_failure_message
def test_custom_failure_message(self):
message = u_('This is a custom message whose id is: %(id_number)s')
id_number = 23
p = EqualsFour(msg=message)
try:
p.unmet(message, id_number=id_number)
self.fail('An exception must have been raised')
except predicates.NotAuthorizedError as e:
self.assertEqual(unicode_text(e), message % dict(id_number=id_number))
开发者ID:984958198,项目名称:tg2,代码行数:9,代码来源:test_predicates.py
示例4: test_content_type
def test_content_type(self):
r = Response()
r.content_type = u_('text/html')
# Verify it's a native string, and not unicode.
assert type(r.content_type) == str
assert r.content_type == 'text/html'
del r.content_type
assert r.content_type is None
开发者ID:TurboGears,项目名称:tg2,代码行数:10,代码来源:test_request_local.py
示例5: test_unauthorized_with_unicode_message
def test_unauthorized_with_unicode_message(self):
# This test is broken on Python 2.4 and 2.5 because the unicode()
# function doesn't work when converting an exception into an unicode
# string (this is, to extract its message).
unicode_msg = u_('请登陆')
environ = {'test_number': 3}
p = EqualsFour(msg=unicode_msg)
try:
p.check_authorization(environ)
self.fail('Authorization must have been rejected')
except predicates.NotAuthorizedError as e:
self.assertEqual(unicode_text(e), unicode_msg)
开发者ID:984958198,项目名称:tg2,代码行数:12,代码来源:test_predicates.py
示例6: test_form_validation_translation
def test_form_validation_translation(self):
if PY3: raise SkipTest()
"""Test translation of form validation error messages"""
form_values = {'title': 'Razer', 'year': "t007"}
# check with language set in request header
resp = self.app.post('/process_form', form_values,
headers={'Accept-Language': 'de,ru,it'})
values = loads(resp.body.decode('utf-8'))
assert "Bitte eine ganze Zahl eingeben" in values['errors']['year'], \
'No German error message: %r' % values['errors']
resp = self.app.post('/process_form', form_values,
headers={'Accept-Language': 'ru,de,it'})
values = loads(resp.body.decode('utf-8'))
assert u_("Введите числовое значение") in values['errors']['year'], \
'No Russian error message: %r' % values['errors']
# check with language set in session
self.app.post('/set_lang/de')
resp = self.app.post('/process_form', form_values,
headers={'Accept-Language': 'ru,it'})
values = loads(resp.body.decode('utf-8'))
assert "Bitte eine ganze Zahl eingeben" in values['errors']['year'], \
'No German error message: %r' % values['errors']
开发者ID:984958198,项目名称:tg2,代码行数:23,代码来源:test_validation.py
示例7: test_form_validation_translation
def test_form_validation_translation(self):
if PY3:
raise SkipTest()
"""Test translation of form validation error messages"""
form_values = {"title": "Razer", "year": "t007"}
# check with language set in request header
resp = self.app.post("/process_form", form_values, headers={"Accept-Language": "de,ru,it"})
values = loads(resp.body.decode("utf-8"))
assert "Bitte eine ganze Zahl eingeben" in values["errors"]["year"], (
"No German error message: %r" % values["errors"]
)
resp = self.app.post("/process_form", form_values, headers={"Accept-Language": "ru,de,it"})
values = loads(resp.body.decode("utf-8"))
assert u_("Введите числовое значение") in values["errors"]["year"], (
"No Russian error message: %r" % values["errors"]
)
# check with language set in session
self.app.post("/set_lang/de")
resp = self.app.post("/process_form", form_values, headers={"Accept-Language": "ru,it"})
values = loads(resp.body.decode("utf-8"))
assert "Bitte eine ganze Zahl eingeben" in values["errors"]["year"], (
"No German error message: %r" % values["errors"]
)
开发者ID:ralphbean,项目名称:tg2,代码行数:24,代码来源:test_validation.py
示例8: test_url_unicode_nonascii
def test_url_unicode_nonascii():
res = url('.', {'p1':u_('àèìòù')})
assert res == '.?p1=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9'
开发者ID:antsfee,项目名称:tg2,代码行数:3,代码来源:test_util.py
示例9: flash_unicode
def flash_unicode(self):
tg.flash(u_("Привет, мир!"))
tg.redirect("/flash_after_redirect")
开发者ID:984958198,项目名称:tg2,代码行数:3,代码来源:test_tg_controller_dispatch.py
示例10: test_flash_unicode
def test_flash_unicode():
resp = app.get('/flash_unicode').follow()
content = resp.body.decode('utf8')
assert u_('Привет, мир!') in content, content
开发者ID:Shamefox,项目名称:tg2,代码行数:4,代码来源:test_url_dispatch.py
示例11: test_url_unicode
def test_url_unicode():
res = url('.', {'p1':u_('v1')})
assert res == '.?p1=v1'
开发者ID:antsfee,项目名称:tg2,代码行数:3,代码来源:test_util.py
示例12: test_list
def test_list():
"""url() can handle list parameters, with unicode too"""
create_request("/")
value = url('/', params=dict(foo=['bar', u_('à')])),
assert '/?foo=bar&foo=%C3%A0' in value, value
开发者ID:Shamefox,项目名称:tg2,代码行数:5,代码来源:test_controllers.py
示例13: test_jinja_i18n_de
def test_jinja_i18n_de():
app = setup_noDB()
resp = app.get('/jinja_i18n_de')
assert u_("Ihre Anwendung läuft jetzt einwandfrei") in resp
开发者ID:Shamefox,项目名称:tg2,代码行数:4,代码来源:test_dotted_rendering.py
示例14: test_unicode_messages
def test_unicode_messages(self):
unicode_msg = u_('请登陆')
p = EqualsTwo(msg=unicode_msg)
environ = {'test_number': 3}
self.eval_unmet_predicate(p, environ, unicode_msg)
开发者ID:984958198,项目名称:tg2,代码行数:5,代码来源:test_predicates.py
示例15: test_list
def test_list():
"""url() can handle list parameters, with unicode too"""
with test_context(None, '/'):
value = url('/', params=dict(foo=['bar', u_('à')])),
assert '/?foo=bar&foo=%C3%A0' in value, value
开发者ID:984958198,项目名称:tg2,代码行数:5,代码来源:test_controllers.py
示例16: test_unicode_default_dispatch
def test_unicode_default_dispatch(self):
r = self.app.get("/sub/%C3%A4%C3%B6")
assert u_("äö") in r.body.decode("utf-8"), r
开发者ID:ralphbean,项目名称:tg2,代码行数:3,代码来源:test_tg_controller_dispatch.py
示例17: index_unicode
def index_unicode(self):
tg.response.charset = None
return u_('Hello World')
开发者ID:984958198,项目名称:tg2,代码行数:3,代码来源:test_tg_controller_dispatch.py
示例18: test_kajiki_i18n
def test_kajiki_i18n():
app = setup_noDB()
resp = app.get('/kajiki_i18n')
assert u_("Your application is now running") in resp
开发者ID:lucius-feng,项目名称:tg2,代码行数:4,代码来源:test_dotted_rendering.py
示例19: test_ticket_2412_with_ordered_arg
def test_ticket_2412_with_ordered_arg(self):
resp = self.app.get("/ticket2412/Abip%C3%B3n")
assert u_("""Abipón""") in resp.body.decode("utf-8"), resp
开发者ID:ralphbean,项目名称:tg2,代码行数:3,代码来源:test_tg_controller_dispatch.py
示例20: test_unicode_default_dispatch
def test_unicode_default_dispatch(self):
r =self.app.get('/sub/%C3%A4%C3%B6')
assert u_("äö") in r.body.decode('utf-8'), r
开发者ID:984958198,项目名称:tg2,代码行数:3,代码来源:test_tg_controller_dispatch.py
注:本文中的tg._compat.u_函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论