Exemplo n.º 1
0
 def test_coerce_to_string(self):
     self.assertEqual(u'1', Parser.coerce_to_string(1))
     self.assertEqual(u'stuff', Parser.coerce_to_string(u'stuff'))
     self.assertEqual(u'stuff', Parser.coerce_to_string('stuff'))
     self.assertEqual(u'st😽uff', Parser.coerce_to_string(u'st😽uff'))
     self.assertRaises(TypeError, Parser.coerce_to_string, {'key': 'value'})
     self.assertRaises(TypeError, Parser.coerce_to_string, None)
Exemplo n.º 2
0
    def url(self, value):

        if isinstance(value, dict):
            # this is the templated url , we need to convert it into actual URL
            template_str = Parser.lowercase_keys(value)['template']
            self.set_template("url", Parser.coerce_to_string(template_str))
            self.__url = value
        else:
            self.__url = value
Exemplo n.º 3
0
 def test_coerce_to_string(self):
     result = Parser.coerce_to_string(bytes("Hello", 'utf-8'))
     self.assertEqual(result, "Hello")