本文整理汇总了Python中clld.db.models.common.Language.__unicode__方法的典型用法代码示例。如果您正苦于以下问题:Python Language.__unicode__方法的具体用法?Python Language.__unicode__怎么用?Python Language.__unicode__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clld.db.models.common.Language
的用法示例。
在下文中一共展示了Language.__unicode__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Base
# 需要导入模块: from clld.db.models.common import Language [as 别名]
# 或者: from clld.db.models.common.Language import __unicode__ [as 别名]
def test_Base(self):
l = Language(id='abc', name='Name')
VersionedDBSession.add(l)
VersionedDBSession.flush()
VersionedDBSession.expunge(l)
l = Language.get('abc')
self.assertEqual(l.name, 'Name')
assert not list(l.history())
# a bit of a hack to test the human readable representations.
# we exploit the fact, that on py2, string and unicode comparison does type
# coercion, while on py3, the two methods should actually return the same string.
self.assertEqual(l.__str__(), l.__unicode__())
Language().__str__()
示例2: test_Base
# 需要导入模块: from clld.db.models.common import Language [as 别名]
# 或者: from clld.db.models.common.Language import __unicode__ [as 别名]
def test_Base(db):
l = Language(id='abc', name='Name')
VersionedDBSession.add(l)
VersionedDBSession.flush()
VersionedDBSession.expunge(l)
l = Language.get('abc', session=VersionedDBSession)
assert l.name == 'Name'
assert not list(l.history())
# a bit of a hack to test the human readable representations.
# we exploit the fact, that on py2, string and unicode comparison does type
# coercion, while on py3, the two methods should actually return the same string.
assert l.__str__() == l.__unicode__()
Language().__str__()
assert repr(l) == "<Language 'abc'>" if PY3 else "<Language u'abc'>"
示例3: test_Base
# 需要导入模块: from clld.db.models.common import Language [as 别名]
# 或者: from clld.db.models.common.Language import __unicode__ [as 别名]
def test_Base(self):
l = Language(id='abc', name='Name')
VersionedDBSession.add(l)
VersionedDBSession.flush()
VersionedDBSession.expunge(l)
#print('pk: %s' % l.pk)
#transaction.commit()
#transaction.begin()
#l = VersionedDBSession.query(Language).get(1)
#print(l)
#l.name = 'New name'
#print('pk: %s' % l.pk)
#transaction.commit()
#transaction.begin()
l = Language.get('abc')
#print(l.version)
self.assertEqual(l.name, 'Name')
l.history()
# a bit of a hack to test the human readable representations.
# we exploit the fact, that on py2, string and unicode comparison does type
# coercion, while on py3, the two methods should actualy return the same string.
self.assertEqual(l.__str__(), l.__unicode__())
Language().__str__()