Add gif parser and tests
@@ -6,13 +6,13 @@ from mitmproxy.test import tutils
|
||||
|
||||
@pytest.mark.parametrize("filename, metadata", {
|
||||
# no textual data
|
||||
"mitmproxy/data/png_parser/ct0n0g04.png": [
|
||||
"mitmproxy/data/image_parser/ct0n0g04.png": [
|
||||
('Format', 'Portable network graphics'),
|
||||
('Size', '32 x 32 px'),
|
||||
('gamma', '1.0')
|
||||
],
|
||||
# with textual data
|
||||
"mitmproxy/data/png_parser/ct1n0g04.png": [
|
||||
"mitmproxy/data/image_parser/ct1n0g04.png": [
|
||||
('Format', 'Portable network graphics'),
|
||||
('Size', '32 x 32 px'),
|
||||
('gamma', '1.0'),
|
||||
@@ -27,7 +27,7 @@ from mitmproxy.test import tutils
|
||||
('Disclaimer', 'Freeware.')
|
||||
],
|
||||
# with compressed textual data
|
||||
"mitmproxy/data/png_parser/ctzn0g04.png": [
|
||||
"mitmproxy/data/image_parser/ctzn0g04.png": [
|
||||
('Format', 'Portable network graphics'),
|
||||
('Size', '32 x 32 px'),
|
||||
('gamma', '1.0'),
|
||||
@@ -42,7 +42,7 @@ from mitmproxy.test import tutils
|
||||
('Disclaimer', 'Freeware.')
|
||||
],
|
||||
# UTF-8 international text - english
|
||||
"mitmproxy/data/png_parser/cten0g04.png": [
|
||||
"mitmproxy/data/image_parser/cten0g04.png": [
|
||||
('Format', 'Portable network graphics'),
|
||||
('Size', '32 x 32 px'),
|
||||
('gamma', '1.0'),
|
||||
@@ -57,13 +57,13 @@ from mitmproxy.test import tutils
|
||||
('Disclaimer', 'Freeware.')
|
||||
],
|
||||
# check gamma value
|
||||
"mitmproxy/data/png_parser/g07n0g16.png": [
|
||||
"mitmproxy/data/image_parser/g07n0g16.png": [
|
||||
('Format', 'Portable network graphics'),
|
||||
('Size', '32 x 32 px'),
|
||||
('gamma', '0.7')
|
||||
],
|
||||
# check aspect value
|
||||
"mitmproxy/data/png_parser/aspect.png": [
|
||||
"mitmproxy/data/image_parser/aspect.png": [
|
||||
('Format', 'Portable network graphics'),
|
||||
('Size', '1280 x 798 px'),
|
||||
('aspect', '72 x 72'),
|
||||
@@ -74,3 +74,26 @@ from mitmproxy.test import tutils
|
||||
def test_parse_png(filename, metadata):
|
||||
with open(tutils.test_data.path(filename), "rb") as f:
|
||||
assert metadata == image_parser.parse_png(f.read())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("filename, metadata", {
|
||||
# check comment
|
||||
"mitmproxy/data/image_parser/hopper.gif": [
|
||||
('Format', 'Compuserve GIF'),
|
||||
('version', 'GIF89a'),
|
||||
('Size', '128 x 128 px'),
|
||||
('background', '0'),
|
||||
('comment', "b'File written by Adobe Photoshop\\xa8 4.0'")
|
||||
],
|
||||
# check background
|
||||
"mitmproxy/data/image_parser/chi.gif": [
|
||||
('Format', 'Compuserve GIF'),
|
||||
('version', 'GIF89a'),
|
||||
('Size', '320 x 240 px'),
|
||||
('background', '248'),
|
||||
('comment', "b'Created with GIMP'")
|
||||
],
|
||||
}.items())
|
||||
def test_parse_gif(filename, metadata):
|
||||
with open(tutils.test_data.path(filename), 'rb') as f:
|
||||
assert metadata == image_parser.parse_gif(f.read())
|
||||
|
||||
BIN
test/mitmproxy/data/image_parser/aspect.gif
Normal file
|
After Width: | Height: | Size: 939 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
BIN
test/mitmproxy/data/image_parser/chi.gif
Normal file
|
After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 273 B After Width: | Height: | Size: 273 B |
|
Before Width: | Height: | Size: 792 B After Width: | Height: | Size: 792 B |
|
Before Width: | Height: | Size: 742 B After Width: | Height: | Size: 742 B |
|
Before Width: | Height: | Size: 753 B After Width: | Height: | Size: 753 B |
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 321 B |
BIN
test/mitmproxy/data/image_parser/hopper.gif
Normal file
|
After Width: | Height: | Size: 15 KiB |