当前位置: 首页>>代码示例>>Python>>正文


Python Language.__str__方法代码示例

本文整理汇总了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__()
开发者ID:Woseseltops,项目名称:clld,代码行数:16,代码来源:test_db_meta.py

示例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'>"
开发者ID:clld,项目名称:clld,代码行数:17,代码来源:test_db_meta.py

示例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__()
开发者ID:mitcho,项目名称:clld,代码行数:26,代码来源:test_db_meta.py


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