OSDN Git Service

refactoring export_pmd
[meshio/pymeshio.git] / test / pmd_test.py
index a4dc095..fa64485 100644 (file)
@@ -2,17 +2,13 @@
 import sys
 import io
 import unittest
+import pymeshio.common
 import pymeshio.pmd
-import pymeshio.pmd.loader
+import pymeshio.pmd.reader
 import pymeshio.pmd.writer
 
 
-PMD_FILE=u'resources/初音ミクVer2.pmd'
-
-
-def test_old_pmd_load():
-    loader=pymeshio.pmd.IO()
-    assert loader.read(PMD_FILE)
+PMD_FILE=pymeshio.common.unicode('resources/初音ミクVer2.pmd')
 
 
 class TestPmd(unittest.TestCase):
@@ -20,26 +16,26 @@ class TestPmd(unittest.TestCase):
     def setUp(self):
         pass
 
-    def test_load(self):
-        model=pymeshio.pmd.loader.load_from_file(PMD_FILE)
+    def test_read(self):
+        model=pymeshio.pmd.reader.read_from_file(PMD_FILE)
         self.assertEqual(pymeshio.pmd.Model,  model.__class__)
-        self.assertEqual(u'初音ミク'.encode('cp932'),  model.name)
-        self.assertEqual(u'Miku Hatsune'.encode('cp932'),  model.english_name)
-        self.assertEqual((
-            u"PolyMo用モデルデータ:初音ミク ver.2.3\n"+
-            u"(物理演算対応モデル)\n"+
-            u"\n"+
-            u"モデリング  :あにまさ氏\n"+
-            u"データ変換  :あにまさ氏\n"+
-            u"Copyright        :CRYPTON FUTURE MEDIA, INC").encode('cp932'),
+        self.assertEqual(pymeshio.common.unicode('初音ミク').encode('cp932'),  model.name)
+        self.assertEqual(pymeshio.common.unicode('Miku Hatsune').encode('cp932'),  model.english_name)
+        self.assertEqual(pymeshio.common.unicode(
+            "PolyMo用モデルデータ:初音ミク ver.2.3\n"+
+            "(物理演算対応モデル)\n"+
+            "\n"+
+            "モデリング   :あにまさ氏\n"+
+            "データ変換   :あにまさ氏\n"+
+            "Copyright :CRYPTON FUTURE MEDIA, INC").encode('cp932'),
             model.comment)
-        self.assertEqual((
-            u"MMD Model: Miku Hatsune ver.2.3\n"+
-            u"(Physical Model)\n"+
-            u"\n"+
-            u"Modeling by      Animasa\n"+
-            u"Converted by     Animasa\n"+
-            u"Copyright                CRYPTON FUTURE MEDIA, INC").encode('cp932'),
+        self.assertEqual(pymeshio.common.unicode(
+            "MMD Model: Miku Hatsune ver.2.3\n"+
+            "(Physical Model)\n"+
+            "\n"+
+            "Modeling by       Animasa\n"+
+            "Converted by      Animasa\n"+
+            "Copyright         CRYPTON FUTURE MEDIA, INC").encode('cp932'),
             model.english_comment)
         self.assertEqual(12354,  len(model.vertices))
         self.assertEqual(22961 * 3,  len(model.indices))
@@ -53,11 +49,12 @@ class TestPmd(unittest.TestCase):
     def test_write(self):
         # read source file
         buf=pymeshio.common.readall(PMD_FILE)
-        # load and write to out
-        model=pymeshio.pmd.loader.load(io.BytesIO(buf))
+        # read and write to out
+        model=pymeshio.pmd.reader.read(io.BytesIO(buf))
         out=io.BytesIO()
         pymeshio.pmd.writer.write(out, model)
         # read out buffer again
-        model2=pymeshio.pmd.loader.load(io.BytesIO(out.getvalue()))
+        model2=pymeshio.pmd.reader.read(io.BytesIO(out.getvalue()))
+        model.diff(model2)
         self.assertEqual(model, model2)