Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo 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('',
               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)