X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test%2Fpmx_test.py;h=e9185eea52ee44da446666f0991410923ca7a0dc;hb=cf6ec3e04ee67bbe635510486475961ed32e46f2;hp=c8e060a2ffc672fb96bf0f071a1dac4fb947a8b5;hpb=c9f342063f2c03949e23a4dd12960efa11fe2cb7;p=meshio%2Fpymeshio.git diff --git a/test/pmx_test.py b/test/pmx_test.py index c8e060a..e9185ee 100644 --- a/test/pmx_test.py +++ b/test/pmx_test.py @@ -1,9 +1,12 @@ # coding: utf-8 -import pymeshio.pmx.loader import unittest +import io +import pymeshio.pmd +import pymeshio.pmx.reader +import pymeshio.pmx.writer -PMX_FILE=u'resources/初音ミクVer2.pmx' +PMX_FILE=pymeshio.unicode('resources/初音ミクVer2.pmx') class TestPmx(unittest.TestCase): @@ -12,25 +15,25 @@ class TestPmx(unittest.TestCase): pass def test_read(self): - model=pymeshio.pmx.loader.load(PMX_FILE) + model=pymeshio.pmx.reader.read_from_file(PMX_FILE) self.assertEqual(pymeshio.pmx.Model, model.__class__) - self.assertEqual(u'初音ミク', model.name) - self.assertEqual(u'Miku Hatsune', model.english_name) - self.assertEqual( - u"PolyMo用モデルデータ:初音ミク ver.2.3\r\n"+ - u"(物理演算対応モデル)\r\n"+ - u"\r\n"+ - u"モデリング :あにまさ氏\r\n"+ - u"データ変換 :あにまさ氏\r\n"+ - u"Copyright :CRYPTON FUTURE MEDIA, INC", + self.assertEqual(pymeshio.unicode('初音ミク'), model.name) + self.assertEqual(pymeshio.unicode('Miku Hatsune'), model.english_name) + self.assertEqual(pymeshio.unicode( + "PolyMo用モデルデータ:初音ミク ver.2.3\r\n"+ + "(物理演算対応モデル)\r\n"+ + "\r\n"+ + "モデリング :あにまさ氏\r\n"+ + "データ変換 :あにまさ氏\r\n"+ + "Copyright :CRYPTON FUTURE MEDIA, INC"), model.comment) - self.assertEqual( - u"MMD Model: Miku Hatsune ver.2.3\r\n"+ - u"(Physical Model)\r\n"+ - u"\r\n"+ - u"Modeling by Animasa\r\n"+ - u"Converted by Animasa\r\n"+ - u"Copyright CRYPTON FUTURE MEDIA, INC", + self.assertEqual(pymeshio.unicode( + "MMD Model: Miku Hatsune ver.2.3\r\n"+ + "(Physical Model)\r\n"+ + "\r\n"+ + "Modeling by Animasa\r\n"+ + "Converted by Animasa\r\n"+ + "Copyright CRYPTON FUTURE MEDIA, INC"), model.english_comment) self.assertEqual(12354, len(model.vertices)) @@ -43,3 +46,14 @@ class TestPmx(unittest.TestCase): self.assertEqual(45, len(model.rigidbodies)) self.assertEqual(27, len(model.joints)) + def test_write(self): + # read source file + buf=pymeshio.common.readall(PMX_FILE) + # read and write to out + model=pymeshio.pmx.reader.read(io.BytesIO(buf)) + out=io.BytesIO() + pymeshio.pmx.writer.write(out, model) + # read out buffer again + model2=pymeshio.pmx.reader.read(io.BytesIO(out.getvalue())) + self.assertEqual(model, model2) +