Ejemplo n.º 1
0
 def test_assemble_option_dict(self):
     input = utils.extract_name_value("a=1 bbb=2.0 cdef=hol%s" % chr(224))
     self.assertEquals(
         utils.assemble_option_dict(input, self.optionspec), {"a": 1, "bbb": 2.0, "cdef": ("hol%s" % chr(224))}
     )
     input = utils.extract_name_value("a=1 b=2.0 c=hol%s" % chr(224))
     self.assertRaises(KeyError, utils.assemble_option_dict, input, self.optionspec)
     input = utils.extract_name_value("a=1 bbb=two cdef=hol%s" % chr(224))
     self.assertRaises(ValueError, utils.assemble_option_dict, input, self.optionspec)
Ejemplo n.º 2
0
 def test_assemble_option_dict(self):
     input = utils.extract_name_value('a=1 bbb=2.0 cdef=hol%s' % chr(224))
     self.assertEqual(
           utils.assemble_option_dict(input, self.optionspec),
           {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224))})
     input = utils.extract_name_value('a=1 b=2.0 c=hol%s' % chr(224))
     self.assertRaises(KeyError, utils.assemble_option_dict,
                       input, self.optionspec)
     input = utils.extract_name_value('a=1 bbb=two cdef=hol%s' % chr(224))
     self.assertRaises(ValueError, utils.assemble_option_dict,
                       input, self.optionspec)
Ejemplo n.º 3
0
 def test_assemble_option_dict(self):
     input = utils.extract_name_value('a=1 bbb=2.0 cdef=hol%s' % chr(224))
     self.assertEquals(
           utils.assemble_option_dict(input, self.optionspec),
           {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224))})
     input = utils.extract_name_value('a=1 b=2.0 c=hol%s' % chr(224))
     self.assertRaises(KeyError, utils.assemble_option_dict,
                       input, self.optionspec)
     input = utils.extract_name_value('a=1 bbb=two cdef=hol%s' % chr(224))
     self.assertRaises(ValueError, utils.assemble_option_dict,
                       input, self.optionspec)
Ejemplo n.º 4
0
 def test_extract_name_value(self):
     self.assertRaises(utils.NameValueError, utils.extract_name_value, "hello")
     self.assertRaises(utils.NameValueError, utils.extract_name_value, "hello")
     self.assertRaises(utils.NameValueError, utils.extract_name_value, "=hello")
     self.assertRaises(utils.NameValueError, utils.extract_name_value, "hello=")
     self.assertRaises(utils.NameValueError, utils.extract_name_value, 'hello="')
     self.assertRaises(utils.NameValueError, utils.extract_name_value, 'hello="something')
     self.assertRaises(utils.NameValueError, utils.extract_name_value, 'hello="something"else')
     output = utils.extract_name_value("""att1=val1 att2=val2 att3="value number '3'" att4=val4""")
     self.assertEquals(output, [("att1", "val1"), ("att2", "val2"), ("att3", "value number '3'"), ("att4", "val4")])
Ejemplo n.º 5
0
 def test_extract_name_value(self):
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       '=hello')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello=')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello="')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello="something')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello="something"else')
     output = utils.extract_name_value(
         """att1=val1 att2=val2 att3="value number '3'" att4=val4""")
     self.assertEqual(output, [('att1', 'val1'), ('att2', 'val2'),
                               ('att3', "value number '3'"),
                               ('att4', 'val4')])
Ejemplo n.º 6
0
 def test_extract_name_value(self):
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       '=hello')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello=')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello="')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello="something')
     self.assertRaises(utils.NameValueError, utils.extract_name_value,
                       'hello="something"else')
     output = utils.extract_name_value(
           """att1=val1 att2=val2 att3="value number '3'" att4=val4""")
     self.assertEqual(output, [('att1', 'val1'), ('att2', 'val2'),
                                ('att3', "value number '3'"),
                                ('att4', 'val4')])