Example #1
0
 def __init__(self):
     self.converters = FakeConvertersDict()
     self.legacy_converters = FakeConvertersDict()
     self.language = clinic.CLanguage(None)
     self.filename = None
     self.destination_buffers = {}
     self.block_parser = clinic.BlockParser('', self.language)
     self.modules = collections.OrderedDict()
     self.classes = collections.OrderedDict()
     clinic.clinic = self
     self.name = "FakeClinic"
     self.line_prefix = self.line_suffix = ''
     self.destinations = {}
     self.add_destination("block", "buffer")
     self.add_destination("file", "buffer")
     self.add_destination("suppress", "suppress")
     d = self.destinations.get
     self.field_destinations = collections.OrderedDict((
         ('docstring_prototype', d('suppress')),
         ('docstring_definition', d('block')),
         ('methoddef_define', d('block')),
         ('impl_prototype', d('block')),
         ('parser_prototype', d('suppress')),
         ('parser_definition', d('block')),
         ('impl_definition', d('block')),
     ))
Example #2
0
 def _test_clinic(self, input, output):
     language = clinic.CLanguage(None)
     c = clinic.Clinic(language, filename="file")
     c.parsers['inert'] = InertParser(c)
     c.parsers['copy'] = CopyParser(c)
     computed = c.parse(input)
     self.assertEqual(output, computed)
Example #3
0
    def _test(self, input, output):
        language = clinic.CLanguage(None)

        blocks = list(clinic.BlockParser(input, language))
        writer = clinic.BlockPrinter(language)
        for block in blocks:
            writer.print_block(block)
        output = writer.f.getvalue()
        assert output == input, "output != input!\n\noutput " + repr(output) + "\n\n input " + repr(input)
Example #4
0
 def __init__(self):
     self.converters = FakeConvertersDict()
     self.legacy_converters = FakeConvertersDict()
     self.language = clinic.CLanguage()
     self.filename = None
     self.block_parser = clinic.BlockParser('', self.language)
     self.modules = collections.OrderedDict()
     clinic.clinic = self
     self.name = "FakeClinic"
Example #5
0
 def test_eol(self):
     # regression test:
     # clinic's block parser didn't recognize
     # the "end line" for the block if it
     # didn't end in "\n" (as in, the last)
     # byte of the file was '/'.
     # so it would spit out an end line for you.
     # and since you really already had one,
     # the last line of the block got corrupted.
     c = clinic.Clinic(clinic.CLanguage(None), filename="file")
     raw = "/*[clinic]\nfoo\n[clinic]*/"
     cooked = c.parse(raw).splitlines()
     end_line = cooked[2].rstrip()
     # this test is redundant, it's just here explicitly to catch
     # the regression test so we don't forget what it looked like
     self.assertNotEqual(end_line, "[clinic]*/[clinic]*/")
     self.assertEqual(end_line, "[clinic]*/")