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
def test__init__(): proj = Project(Window) assert proj.path is None eq_(proj.window, Window) eq_(len(proj.editors), 0) eq_(proj.serial_cache, proj.serialize())