def testNewer(self): r = das.read(self.Newer) das.write(r, self.OutputFile) self.assertEqual(das.read(self.Newer), das.read(self.OutputFile)) self.assertNotEqual( das.read(self.Newer, schema_type=None, ignore_meta=True), das.read(self.OutputFile, schema_type=None, ignore_meta=True))
def test3(self): r0 = das.make_default("testmultiline.MyStruct") r0.comment = u"""昨日 今日 明日""" das.write(r0, self.OutputFile) r1 = das.read(self.OutputFile) self.assertEqual(r0.comment, r1.comment)
def test2(self): r0 = das.make_default("testmultiline.MyStruct") r0.comment = u"""hello world. Be happy!""" das.write(r0, self.OutputFile) r1 = das.read(self.OutputFile) self.assertEqual(r0.comment, r1.comment)
def process(self): fp = self.input("filepath").receive() if fp.isEOP(): return False fv = fp.value() fp.drop() dp = self.input("dasObj").receive() if dp.isEOP(): return False dv = dp.value() dp.drop() das.write(dv, fv) return True
def testCompare2(self): hud1 = das.read(self.InputFile, schema_type="hud.HUD") das.write(hud1, self.OutputFile) hud2 = das.read(self.OutputFile, schema_type="hud.HUD") hud2.text.elements[2].opacity = 0.5 self.assertNotEqual(hud1, hud2)
def testCompare1(self): hud1 = das.read(self.InputFile, schema_type="hud.HUD") das.write(hud1, self.OutputFile) hud2 = das.read(self.OutputFile, schema_type="hud.HUD") self.assertEqual(hud1, hud2)
def testWrite1(self): das.write(das.read(self.InputFile, schema_type="hud.HUD"), self.OutputFile) self.assertTrue(os.path.isfile(self.OutputFile))
def testNew(self): r = das.read(self.InputFile) das.write(r, self.OutputFile) with open(self.OutputFile, "r") as f: d = eval(f.read()) self.assertEqual(d["newField"] == ["hello", "world"], True)
def testSaveInvalidValue(self): rv = das.read(self.TestDir + "/test1.tl", schema_type="timeline.ClipSource") with self.assertRaises(das.ValidationError): rv.clipRange = (1, 100, 10) das.write(rv, self.OutputFile)
def testSaveValue(self): rv = das.read(self.TestDir + "/test1.tl", schema_type="timeline.ClipSource") rv.clipRange = [1, 100] das.write(rv, self.OutputFile) self.assertTrue(os.path.isfile(self.OutputFile))
def testSaveNone2(self): rv = das.read(self.TestDir + "/test0.tl", schema_type="timeline.ClipSource") with self.assertRaises(das.ValidationError): rv.dataRange = None das.write(rv, self.OutputFile)
def test_mixin1(): print("=== Mixin tests using timeline.ClipSource schema type ===") class Range(das.Mixin): @classmethod def get_schema_type(klass): return "timeline.Range" def __init__(self, *args, **kwargs): super(Range, self).__init__(*args, **kwargs) def expand(self, start, end): cs, ce = self[0], self[1] if start < cs: cs = start if end > ce: ce = end self[0], self[1] = cs, ce class ClipSource(das.Mixin): @classmethod def get_schema_type(klass): return "timeline.ClipSource" def __init__(self, *args, **kwargs): super(ClipSource, self).__init__(*args, **kwargs) def set_media(self, path): _, ext = map(lambda x: x.lower(), os.path.splitext(path)) if ext == ".fbx": print("Get range from FBX file") elif ext == ".abc": print("Get range from Alembic file") elif ext == ".mov": print("Get range from Movie file") self.media = os.path.abspath(path).replace("\\", "/") def set_clip_offsets(self, start, end): data_start, data_end = self.dataRange clip_start = min(data_end, data_start + max(0, start)) clip_end = max(data_start, data_end + min(end, 0)) if clip_start == data_start and clip_end == data_end: self.clipRange = None else: self.clipRange = (clip_start, clip_end) das.register_mixins(Range, ClipSource) print("-- make def (1)") dv = das.make_default("timeline.ClipSource") print("-- write (1)") das.write(dv, "./out.tl") print("-- make def (2)") cs = das.make_default("timeline.ClipSource") print("-- read (1)") cs = das.read("./out.tl") das.pprint(cs) cs.dataRange = (100, 146) cs.dataRange.expand(102, 150) cs.set_media("./source.mov") cs.set_clip_offsets(1, -1) das.pprint(cs) print("-- write (2)") das.write(cs, "./out.tl") c = das.copy(cs) das.pprint(c) for k, v in c.iteritems(): print("%s = %s" % (k, v)) os.remove("./out.tl")
def test1(self): r = self._makeValue() das.write(r, self.OutputFile)
def testNotEqual(self): das.write(self._makeOne(), self.OutputFile) p0 = self._makeOne() p1 = das.read(self.OutputFile) p1.gender = u"女" self.assertFalse(p0 == p1)
def testEqual(self): das.write(self._makeOne(), self.OutputFile) p0 = self._makeOne() p1 = das.read(self.OutputFile) self.assertTrue(p0 == p1)
def test1(self): r = das.make_default("testalias.MyStruct") r.margin = "both" das.write(r, self.OutputFile)