Esempio n. 1
0
    def test_encode_decode(self):
        """Test that dmtxwrite can decode this library's output
        to the correct string"""

        for string in MatrixTest.test_strings:

            encoder = DataMatrixEncoder(string)
            encoder.save("datamatrix-test.png")

            if not os.path.exists(dmtxread_path):
                print "%r does not exist, skipping decoding tests" % dmtxread_path
            else:
                fin = os.popen("%s datamatrix-test.png" % (dmtxread_path))
                self.assertEqual(fin.readline()[:-1], string)
Esempio n. 2
0
    def test_encode_decode(self):
        """Test that dmtxwrite can decode this library's output
        to the correct string"""

        for string in MatrixTest.test_strings:

            encoder = DataMatrixEncoder(string)
            encoder.save("datamatrix-test.png")

            if not os.path.exists(dmtxread_path):
                print "%r does not exist, skipping decoding tests" % dmtxread_path
            else:
                fin = os.popen("%s datamatrix-test.png" % (dmtxread_path))
                self.assertEqual(fin.readline()[:-1], string)
Esempio n. 3
0
    def test_against_dmtx(self):
        """Compare the output of this library with that of dmtxwrite"""

        for string in MatrixTest.test_strings:
            encoder = DataMatrixEncoder(string)
            mine = encoder.get_ascii()

            if not os.path.exists(dmtxwrite_path):
                print "%r does not exist, skipping encoding tests" % dmtxwrite_path
            else:
                fin = os.popen("%s '%s'" % (dmtxwrite_path, string))
                output = ""
                while True:
                    line = fin.readline()
                    if not line:
                        break
                    if line[0] == 'X':
                        output += line
                self.assertEqual(output, mine)
Esempio n. 4
0
    def test_against_dmtx(self):
        """Compare the output of this library with that of dmtxwrite"""

        for string in MatrixTest.test_strings:
            encoder = DataMatrixEncoder(string)
            mine = encoder.get_ascii()

            if not os.path.exists(dmtxwrite_path):
                print "%r does not exist, skipping encoding tests" % dmtxwrite_path
            else:
                fin = os.popen("%s '%s'" % (dmtxwrite_path, string))
                output = ""
                while True:
                    line = fin.readline()
                    if not line:
                        break
                    if line[0] == 'X':
                        output += line
                self.assertEqual(output, mine)