本文整理汇总了Python中editxt.project.Project._deserialize方法的典型用法代码示例。如果您正苦于以下问题:Python Project._deserialize方法的具体用法?Python Project._deserialize怎么用?Python Project._deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类editxt.project.Project
的用法示例。
在下文中一共展示了Project._deserialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import _deserialize [as 别名]
def test(serial):
m = Mocker()
proj = Project(None)
log = m.replace(mod, 'log')
nsdat = m.replace(fn, 'NSData')
nspls = m.replace(fn, 'NSPropertyListSerialization')
create_editor_with_state = m.method(Project.create_editor_with_state)
create_editor = m.method(Project.create_editor)
proj.editors = docs = m.mock(KVOList)
if "path" in serial:
data = nsdat.dataWithContentsOfFile_(serial["path"]) >> m.mock()
serial_, format, error = nspls. \
propertyListFromData_mutabilityOption_format_errorDescription_( \
data, NSPropertyListImmutable, None, None) >> ({}, m.mock(), None)
else:
serial_ = serial
docs_ = serial_.get("documents", [])
for item in docs_:
create_editor_with_state(item)
if item == "doc_not_found":
m.throw(Exception("document not found"))
log.warn("cannot open document: %r" % item)
#proj._is_dirty = True
bool(docs); m.result(bool(docs_))
if not docs_:
create_editor()
#proj._is_dirty = True
with m:
proj._deserialize(serial)
if "path" in serial:
eq_(proj.path, serial["path"])
assert "name" not in serial
else:
eq_(proj.name, serial.get("name", const.UNTITLED_PROJECT_NAME))
eq_(proj.expanded, serial.get("expanded", True))
eq_([r.path for r in proj.recent], serial.get("recent", []))