本文整理汇总了Python中editxt.project.Project.editors方法的典型用法代码示例。如果您正苦于以下问题:Python Project.editors方法的具体用法?Python Project.editors怎么用?Python Project.editors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类editxt.project.Project
的用法示例。
在下文中一共展示了Project.editors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import editors [as 别名]
def test(c):
def objcstr(value):
value = ak.NSString.alloc().initWithString_(value)
isinstance(value, objc.pyobjc_unicode), (type(value), value)
return value
def check(flag, key, serial, value=None):
if flag:
assert key in serial, (key, serial)
if value is not None:
eq_(serial[key], value)
else:
assert key not in serial, key
proj = Project(None)
recent = [objcstr("/file.txt"), objcstr("/doc.xml")]
if c.recent:
proj.recent.extend(Recent(p) for p in recent)
if c.name:
proj.name = objcstr("<name>")
if c.docs:
proj.editors = [MockDoc(1)]
proj.expanded = c.expn
serial = proj.serialize()
check(False, "path", serial, proj.path)
check(c.name, "name", serial, proj.name)
check(c.docs, "documents", serial)
check(True, "expanded", serial, c.expn)
check(c.recent, "recent", serial, recent)
dump_yaml(serial) # verify that it does not crash
示例2: do_test
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import editors [as 别名]
def do_test(template):
proj = Project(None)
temp_docs = proj.editors
try:
m = Mocker()
all_docs = []
dirty_docs = []
for item in template:
doc = m.mock(Editor)
all_docs.append(doc)
doc.is_dirty >> (item == "d")
if item == "d":
dirty_docs.append(doc)
proj.editors = all_docs
with m:
result = list(proj.dirty_editors())
assert len(dirty_docs) == template.count("d")
assert dirty_docs == result, "%r != %r" % (dirty_docs, result)
finally:
proj.editors = temp_docs