コード例 #1
0
 def test_identity(self):
   self.assertEqual(
     data_urlparse(data_urlencode(png, b('image/png'), charset=None)),
     (png, (b('image'), b('png'), {}))
   )
   self.assertEqual(
     data_urlparse(data_urlencode(png, b('image/png'),
                                  charset=None, encoder=None)),
     (png, (b('image'), b('png'), {}))
   )
コード例 #2
0
 def test_parsing(self):
   raw_bytes, mime_type = data_urlparse(sample_data_url)
   self.assertEqual(raw_bytes, png)
   self.assertEqual(mime_type[:2], (b('text'), b('css')))
   self.assertDictEqual(mime_type[2], {
     b('charset'): b('utf-8'),
     })
   raw_bytes, mime_type = data_urlparse(rfc_note_data_url)
   self.assertEqual(raw_bytes, b('A brief note'))
   self.assertEqual(mime_type[:2], (b('text'), b('plain')))
   self.assertDictEqual(mime_type[2], {
     b('charset'): b('US-ASCII'),
     })
コード例 #3
0
 def test_parsing_no_metadata(self):
   raw_bytes, mime_type = data_urlparse(no_meta_data_url)
   self.assertEqual(raw_bytes, png)
   self.assertEqual(mime_type[:2], (b('text'), b('plain')))
   self.assertDictEqual(mime_type[2], {
     b('charset'): b('US-ASCII'),
     })