OSDN Git Service

test.py for unittest. only braille test is added so far.
authorTakuya Nishimoto <nishimotz@gmail.com>
Mon, 17 Mar 2014 07:43:38 +0000 (16:43 +0900)
committerTakuya Nishimoto <nishimotz@gmail.com>
Mon, 17 Mar 2014 07:43:38 +0000 (16:43 +0900)
jptools/jpBrailleRunner.py
jptools/test.cmd [new file with mode: 0644]
jptools/test.py [new file with mode: 0644]

index 15626c9..ed80364 100644 (file)
@@ -84,6 +84,7 @@ def pass1():
                                                f.write("comment: " + t['comment'].encode('utf-8') + "\n")\r
                                        f.write("\n")\r
                print 'h1: %d error(s). see %s' % (count, outfile)\r
+       return (count, outfile)\r
        \r
 def pass2(verboseMode=False):\r
        global output\r
@@ -163,6 +164,7 @@ def pass2(verboseMode=False):
                                        f.write(log)\r
                                        f.write("\n")\r
                print 'h2: %d error(s). see %s' % (count, outfile)\r
+       return (count, outfile)\r
 \r
 def make_doc():\r
        outfile = '__jpBrailleHarness.t2t'\r
@@ -229,22 +231,9 @@ if __name__ == '__main__':
                                          type="int",\r
                                          default=1,\r
                                          help="number for timeit")\r
-       parser.add_option("-o", "--outposTest",\r
-                                         action="store_true",\r
-                                         dest="outpos_test",\r
-                                         default=False,\r
-                                         help="outpos test")\r
        (options, args) = parser.parse_args()\r
 \r
-       if options.outpos_test == True:\r
-               # translate([b'louis/tables/en-us-g2.ctb'], 'Hello world!')\r
-               inPos  = [0, 0, 1, 2, 3, 4, 5, 6, 6, 11]\r
-               inlen  = len('Hello world!')\r
-               outlen = len(',hello _w6')\r
-               outPos = translator2.makeOutPos(inPos, inlen, outlen)\r
-               print outPos \r
-               assert outPos == [1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 9]\r
-       elif options.make_doc == True:\r
+       if options.make_doc == True:\r
                make_doc()\r
        elif options.pass1_only == True:\r
                t = timeit.Timer(stmt=pass1)\r
diff --git a/jptools/test.cmd b/jptools/test.cmd
new file mode 100644 (file)
index 0000000..a8cf777
--- /dev/null
@@ -0,0 +1 @@
+python test.py
diff --git a/jptools/test.py b/jptools/test.py
new file mode 100644 (file)
index 0000000..8957538
--- /dev/null
@@ -0,0 +1,17 @@
+# -*- coding: UTF-8 -*-
+
+import unittest
+import jpBrailleRunner
+
+class JpBrailleTests(unittest.TestCase):
+
+       def test_pass1(self):
+               count, outfile = jpBrailleRunner.pass1()
+               self.assertEqual(count, 0)
+
+       def test_pass2(self):
+               count, outfile = jpBrailleRunner.pass2()
+               self.assertEqual(count, 0)
+
+if __name__ == '__main__':
+       unittest.main()