本文整理匯總了Python中clld.db.models.common.Language.__str__方法的典型用法代碼示例。如果您正苦於以下問題:Python Language.__str__方法的具體用法?Python Language.__str__怎麽用?Python Language.__str__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類clld.db.models.common.Language
的用法示例。
在下文中一共展示了Language.__str__方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_Base
# 需要導入模塊: from clld.db.models.common import Language [as 別名]
# 或者: from clld.db.models.common.Language import __str__ [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 __str__ [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 __str__ [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__()