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


Python Named.asdict方法代码示例

本文整理汇总了Python中dictalchemy.tests.Named.asdict方法的典型用法代码示例。如果您正苦于以下问题:Python Named.asdict方法的具体用法?Python Named.asdict怎么用?Python Named.asdict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dictalchemy.tests.Named的用法示例。


在下文中一共展示了Named.asdict方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fromdict_allow_pk

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_fromdict_allow_pk(self):
     s = self.session
     named = Named('a name')
     s.add(named)
     s.commit()
     new = {'id': 7}
     named.fromdict(new, allow_pk=True)
     assert named.asdict() == {'id': new['id'], 'name': named.name}
开发者ID:Myconomy,项目名称:dictalchemy,代码行数:10,代码来源:test_fromdict.py

示例2: test_simple

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_simple(self):
     s = self.session
     named = Named('a name')
     s.add(named)
     s.commit()
     new = {'name': 'other name'}
     named.fromdict(new)
     assert named.asdict() == {'id': named.id, 'name': new['name']}
开发者ID:Myconomy,项目名称:dictalchemy,代码行数:10,代码来源:test_fromdict.py

示例3: test_named_with_save

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_named_with_save(self):
     named = Named('a name')
     self.session.add(named)
     self.session.commit()
     assert named.asdict() == {'id': named.id, 'name': named.name}
开发者ID:cheungpat,项目名称:dictalchemy,代码行数:7,代码来源:test_asdict.py

示例4: test_named_without_save

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_named_without_save(self):
     named = Named('a name')
     assert named.asdict() == {'id': None, 'name': named.name}
开发者ID:cheungpat,项目名称:dictalchemy,代码行数:5,代码来源:test_asdict.py

示例5: test_exclude_pk

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_exclude_pk(self):
     named = Named('a name')
     self.session.add(named)
     self.session.commit()
     assert named.asdict(exclude_pk=True) == {'name': named.name}
开发者ID:cheungpat,项目名称:dictalchemy,代码行数:7,代码来源:test_asdict.py

示例6: test_exclude_flag

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_exclude_flag(self):
     named = Named('a name')
     assert named.asdict(exclude=['id']) == {'name': 'a name'}
开发者ID:cheungpat,项目名称:dictalchemy,代码行数:5,代码来源:test_asdict.py

示例7: test_dict

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_dict(self):
     named = Named('a name')
     named.asdict() == dict(named)
开发者ID:cheungpat,项目名称:dictalchemy,代码行数:5,代码来源:test_asdict.py

示例8: test_only_overrides_exclude

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_only_overrides_exclude(self):
     named = Named('a name')
     assert 'name' in dict(named)
     assert 'id' in dict(named)
     assert 'name' not in named.asdict(only=['id'], exclude=['id'])
     assert 'id' not in named.asdict(only=['name'], exclude=['name'])
开发者ID:cheungpat,项目名称:dictalchemy,代码行数:8,代码来源:test_asdict.py

示例9: test_only

# 需要导入模块: from dictalchemy.tests import Named [as 别名]
# 或者: from dictalchemy.tests.Named import asdict [as 别名]
 def test_only(self):
     named = Named('a name')
     assert 'name' in dict(named)
     assert 'id' in dict(named)
     assert 'name' not in named.asdict(only=['id'])
     assert 'id' not in named.asdict(only=['name'])
开发者ID:cheungpat,项目名称:dictalchemy,代码行数:8,代码来源:test_asdict.py


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