示例#1
0
    def testParseSignatures_TrickySignatures(self):
        file_contents = '\n'.join([x[0] for x in TRICKY_SIGNATURES])
        infile = StringIO.StringIO(file_contents)
        signatures = gs.ParseSignatures(infile)
        self.assertEqual(len(TRICKY_SIGNATURES), len(signatures))

        # We assume signatures are in order.
        for i in xrange(len(TRICKY_SIGNATURES)):
            self.assertEqual(TRICKY_SIGNATURES[i][1],
                             signatures[i],
                             msg='Expected %s\nActual %s\nFor %s' %
                             (TRICKY_SIGNATURES[i][1], signatures[i],
                              TRICKY_SIGNATURES[i][0]))
示例#2
0
    def testParseSignatures_CommentsIgnored(self):
        my_sigs = []
        my_sigs.append('# a comment')
        my_sigs.append(SIMPLE_SIGNATURES[0][0])
        my_sigs.append('# another comment')
        my_sigs.append(SIMPLE_SIGNATURES[0][0])
        my_sigs.append('# a third comment')
        my_sigs.append(SIMPLE_SIGNATURES[0][0])

        file_contents = '\n'.join(my_sigs)
        infile = StringIO.StringIO(file_contents)
        signatures = gs.ParseSignatures(infile)
        self.assertEqual(3, len(signatures))
示例#3
0
 def testParseSignatures_EmptyFile(self):
     # Empty file just generates empty signatures.
     infile = StringIO.StringIO()
     signatures = gs.ParseSignatures(infile)
     self.assertEqual(0, len(signatures))