Ejemplo n.º 1
0
 def testOneLineLineCount(self):
     """
     If a multiline string has one thing appended to it, its line count
     must be one.
     """
     s = MultilineString()
     s.append('test')
     self.assertEqual(1, s.lineCount())
Ejemplo n.º 2
0
 def testExtendTwoLinesLineCount(self):
     """
     If a multiline string is extended by two strings, its line count
     must be 2.
     """
     s = MultilineString()
     s.extend(['test1', 'test2'])
     self.assertEqual(2, s.lineCount())
Ejemplo n.º 3
0
 def testTwoLinesLineCount(self):
     """
     If a multiline string has two things appended to it, its line count
     must be 2.
     """
     s = MultilineString()
     s.append('test1')
     s.append('test2')
     self.assertEqual(2, s.lineCount())
Ejemplo n.º 4
0
 def testAppendVerbatimLineCount(self):
     """
     If a multiline string is given a verbatim string to append, its
     line count must be correct.
     """
     s = MultilineString()
     s.indent()
     s.append('test1')
     s.append('      test2\n      test3', verbatim=True)
     s.append('test4')
     self.assertEqual(4, s.lineCount())
Ejemplo n.º 5
0
    def compare(self, other):
        """
        Compare our parameters against another C{DatabaseParameters} instance.

        @param other: A C{DatabaseParameters} instance.
        @return: A C{str} summary of the parameter differences if any, else
            C{None}.
        """
        err = MultilineString()
        err.append('Summary of differences:')
        err.indent()

        ourLandmarks = self.landmarkFinderNames()
        otherLandmarks = other.landmarkFinderNames()
        if ourLandmarks != otherLandmarks:
            err.append("Param 'landmarks' values %r and %r differ." %
                       (ourLandmarks, otherLandmarks))

        ourTrigPoints = self.trigPointFinderNames()
        otherTrigPoints = other.trigPointFinderNames()
        if ourTrigPoints != otherTrigPoints:
            err.append("Param 'trigPoints' values %r and %r differ." %
                       (ourTrigPoints, otherTrigPoints))

        for param in ('limitPerLandmark', 'maxDistance', 'minDistance',
                      'distanceBase', 'featureLengthBase',
                      'randomLandmarkDensity', 'randomTrigPointDensity',
                      'acAlphaHelixFilename', 'acAlphaHelix310Filename',
                      'acAlphaHelixCombinedFilename', 'acAlphaHelixPiFilename',
                      'acExtendedStrandFilename'):
            ours = getattr(self, param)
            others = getattr(other, param)
            if ours != others:
                err.append('Param %r values %r and %r differ.' %
                           (param, ours, others))

        # We have an error if the multi-line string result has more than
        # the initial 'Summary of differences' heading line.
        return str(err) if err.lineCount() > 1 else None