Example #1
0
    def test_reparsing(self):
        for string, result in examples.items():  # @UnusedVariable
            parsed = DocStringInfo.parse(string)
            converted = "%s" % parsed
            reparsed = DocStringInfo.parse(converted)

            msg = "First string:\n%s\nParsed as:\n%s\n" % (add_prefix(string, "|"), add_prefix("%r" % parsed, "|"))

            msg += "Converted:\n%s\nReparsed as:\n%s\n" % (add_prefix(converted, "|"), add_prefix("%r" % reparsed, "|"))

            self.assertEqual(parsed, reparsed, msg=msg)
Example #2
0
def test_reparsing():
    for string, result in examples.items():  #@UnusedVariable
        parsed = DocStringInfo.parse(string)
        converted = "%s" % parsed
        reparsed = DocStringInfo.parse(converted)

        msg = ('First string:\n%s\nParsed as:\n%s\n' %
               (add_prefix(string, '|'), add_prefix('%r' % parsed, '|')))

        msg += ('Converted:\n%s\nReparsed as:\n%s\n' %
                (add_prefix(converted, '|'), add_prefix('%r' % reparsed, '|')))

        assert parsed == reparsed
Example #3
0
    def __str__(self):
        error, where, stack = self.args
        assert isinstance(error, str), error
        s = ""
#         if False: # we have solved in a different way
#             if stack:
#                 s += '\n' + indent(stack,'S ') + '\n'
        s += error.strip()
        
        if where is not None:
            from contracts.interface import add_prefix
            ws = where.__str__()
            assert isinstance(ws, str), (ws, type(where))
            s += "\n\n" + add_prefix(ws, ' ')
        return s
Example #4
0
    def __str__(self):
        error, where, _stack = self.args
        assert isinstance(error, str), error
        s = ""
        #         if False: # we have solved in a different way
        #             if stack:
        #                 s += '\n' + indent(stack,'S ') + '\n'
        s += error.strip()

        if where is not None:
            from contracts.interface import add_prefix
            ws = where.__str__()
            assert isinstance(ws, str), (ws, type(where))
            s += "\n\n" + add_prefix(ws, ' ')
        return s