Ejemplo n.º 1
0
 def setUp(self):
     document = utils.new_document('test data')
     document += nodes.paragraph('', 'Paragraph 1.')
     blist = nodes.bullet_list()
     for i in range(1, 6):
         item = nodes.list_item()
         for j in range(1, 4):
             item += nodes.paragraph('', 'Item %s, paragraph %s.' % (i, j))
         blist += item
     document += blist
     self.document = document
Ejemplo n.º 2
0
 def setUp(self):
     document = utils.new_document('test data')
     document += nodes.paragraph('', 'Paragraph 1.')
     blist = nodes.bullet_list()
     for i in range(1, 6):
         item = nodes.list_item()
         for j in range(1, 4):
             item += nodes.paragraph('', 'Item %s, paragraph %s.' % (i, j))
         blist += item
     document += blist
     self.document = document
Ejemplo n.º 3
0
 def test_extract_extension_options(self):
     field_list = nodes.field_list()
     field_list += nodes.field("", nodes.field_name("", "a"), nodes.field_body("", nodes.paragraph("", "1")))
     field_list += nodes.field("", nodes.field_name("", "bbb"), nodes.field_body("", nodes.paragraph("", "2.0")))
     field_list += nodes.field(
         "", nodes.field_name("", "cdef"), nodes.field_body("", nodes.paragraph("", u"hol\u00e0"))
     )
     field_list += nodes.field("", nodes.field_name("", "empty"), nodes.field_body())
     self.assertEquals(
         utils.extract_extension_options(field_list, self.optionspec),
         {"a": 1, "bbb": 2.0, "cdef": u"hol\u00e0", "empty": None},
     )
     self.assertRaises(KeyError, utils.extract_extension_options, field_list, {})
     field_list += nodes.field(
         "",
         nodes.field_name("", "cdef"),
         nodes.field_body("", nodes.paragraph("", "one"), nodes.paragraph("", "two")),
     )
     self.assertRaises(utils.BadOptionDataError, utils.extract_extension_options, field_list, self.optionspec)
     field_list[-1] = nodes.field(
         "", nodes.field_name("", "cdef bad"), nodes.field_body("", nodes.paragraph("", "no arguments"))
     )
     self.assertRaises(utils.BadOptionError, utils.extract_extension_options, field_list, self.optionspec)
     field_list[-1] = nodes.field(
         "", nodes.field_name("", "cdef"), nodes.field_body("", nodes.paragraph("", "duplicate"))
     )
     self.assertRaises(utils.DuplicateOptionError, utils.extract_extension_options, field_list, self.optionspec)
     field_list[-2] = nodes.field(
         "", nodes.field_name("", "unkown"), nodes.field_body("", nodes.paragraph("", "unknown"))
     )
     self.assertRaises(KeyError, utils.extract_extension_options, field_list, self.optionspec)
Ejemplo n.º 4
0
 def test_extract_extension_options(self):
     field_list = nodes.field_list()
     field_list += nodes.field(
         '', nodes.field_name('', 'a'),
         nodes.field_body('', nodes.paragraph('', '1')))
     field_list += nodes.field(
         '', nodes.field_name('', 'bbb'),
         nodes.field_body('', nodes.paragraph('', '2.0')))
     field_list += nodes.field(
         '', nodes.field_name('', 'cdef'),
         nodes.field_body(
             '',
             nodes.paragraph('', unicode(b('hol%s' % chr(224)),
                                         'iso-8859-1'))))
     field_list += nodes.field('', nodes.field_name('', 'empty'),
                               nodes.field_body())
     self.assertEquals(
         utils.extract_extension_options(field_list, self.optionspec), {
             'a': 1,
             'bbb': 2.0,
             'cdef': unicode(b('hol%s' % chr(224)), 'iso-8859-1'),
             'empty': None
         })
     self.assertRaises(KeyError, utils.extract_extension_options,
                       field_list, {})
     field_list += nodes.field(
         '', nodes.field_name('', 'cdef'),
         nodes.field_body('', nodes.paragraph('', 'one'),
                          nodes.paragraph('', 'two')))
     self.assertRaises(utils.BadOptionDataError,
                       utils.extract_extension_options, field_list,
                       self.optionspec)
     field_list[-1] = nodes.field(
         '', nodes.field_name('', 'cdef bad'),
         nodes.field_body('', nodes.paragraph('', 'no arguments')))
     self.assertRaises(utils.BadOptionError,
                       utils.extract_extension_options, field_list,
                       self.optionspec)
     field_list[-1] = nodes.field(
         '', nodes.field_name('', 'cdef'),
         nodes.field_body('', nodes.paragraph('', 'duplicate')))
     self.assertRaises(utils.DuplicateOptionError,
                       utils.extract_extension_options, field_list,
                       self.optionspec)
     field_list[-2] = nodes.field(
         '', nodes.field_name('', 'unkown'),
         nodes.field_body('', nodes.paragraph('', 'unknown')))
     self.assertRaises(KeyError, utils.extract_extension_options,
                       field_list, self.optionspec)
Ejemplo n.º 5
0
 def test_extract_extension_options(self):
     field_list = nodes.field_list()
     field_list += nodes.field(
           '', nodes.field_name('', 'a'),
           nodes.field_body('', nodes.paragraph('', '1')))
     field_list += nodes.field(
           '', nodes.field_name('', 'bbb'),
           nodes.field_body('', nodes.paragraph('', '2.0')))
     field_list += nodes.field(
           '', nodes.field_name('', 'cdef'),
           nodes.field_body('', nodes.paragraph('',
               unicode(b('hol%s' % chr(224)), 'iso-8859-1'))))
     field_list += nodes.field(
           '', nodes.field_name('', 'empty'), nodes.field_body())
     self.assertEquals(
           utils.extract_extension_options(field_list, self.optionspec),
           {'a': 1, 'bbb': 2.0,
            'cdef': unicode(b('hol%s' % chr(224)), 'iso-8859-1'),
            'empty': None})
     self.assertRaises(KeyError, utils.extract_extension_options,
                       field_list, {})
     field_list += nodes.field(
           '', nodes.field_name('', 'cdef'),
           nodes.field_body('', nodes.paragraph('', 'one'),
                            nodes.paragraph('', 'two')))
     self.assertRaises(utils.BadOptionDataError,
                       utils.extract_extension_options,
                       field_list, self.optionspec)
     field_list[-1] = nodes.field(
           '', nodes.field_name('', 'cdef bad'),
           nodes.field_body('', nodes.paragraph('', 'no arguments')))
     self.assertRaises(utils.BadOptionError,
                       utils.extract_extension_options,
                       field_list, self.optionspec)
     field_list[-1] = nodes.field(
           '', nodes.field_name('', 'cdef'),
           nodes.field_body('', nodes.paragraph('', 'duplicate')))
     self.assertRaises(utils.DuplicateOptionError,
                       utils.extract_extension_options,
                       field_list, self.optionspec)
     field_list[-2] = nodes.field(
           '', nodes.field_name('', 'unkown'),
           nodes.field_body('', nodes.paragraph('', 'unknown')))
     self.assertRaises(KeyError, utils.extract_extension_options,
                       field_list, self.optionspec)