mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 14:58:38 +00:00
Added test
This commit is contained in:
parent
e81144e26b
commit
8ca29679df
@ -91,11 +91,12 @@ def parse_ico(data: bytes) -> Metadata:
|
|||||||
for i, image in enumerate(img.images):
|
for i, image in enumerate(img.images):
|
||||||
parts.append(
|
parts.append(
|
||||||
(
|
(
|
||||||
'Image {}'.format(i), "Size: {} x {}\n "
|
'Image {}'.format(i+1), "Size: {} x {}\n"
|
||||||
"Bits per pixel: {}\n "
|
"{: >18}Bits per pixel: {}\n"
|
||||||
"PNG: {}".format(256 if not image.width else image.width,
|
"{: >18}PNG: {}".format(256 if not image.width else image.width,
|
||||||
256 if not image.height else image.height,
|
256 if not image.height else image.height,
|
||||||
image.bpp, image.is_png)
|
'', image.bpp,
|
||||||
|
'', image.is_png)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -167,3 +167,26 @@ def test_parse_gif(filename, metadata):
|
|||||||
def test_parse_jpeg(filename, metadata):
|
def test_parse_jpeg(filename, metadata):
|
||||||
with open(tutils.test_data.path(filename), 'rb') as f:
|
with open(tutils.test_data.path(filename), 'rb') as f:
|
||||||
assert metadata == image_parser.parse_jpeg(f.read())
|
assert metadata == image_parser.parse_jpeg(f.read())
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("filename, metadata", {
|
||||||
|
"mitmproxy/data/image.ico": [
|
||||||
|
('Format', 'ICO'),
|
||||||
|
('Number of images', '3'),
|
||||||
|
('Image 1', "Size: {} x {}\n"
|
||||||
|
"{: >18}Bits per pixel: {}\n"
|
||||||
|
"{: >18}PNG: {}".format(48, 48, '', 24, '', False)
|
||||||
|
),
|
||||||
|
('Image 2', "Size: {} x {}\n"
|
||||||
|
"{: >18}Bits per pixel: {}\n"
|
||||||
|
"{: >18}PNG: {}".format(32, 32, '', 24, '', False)
|
||||||
|
),
|
||||||
|
('Image 3', "Size: {} x {}\n"
|
||||||
|
"{: >18}Bits per pixel: {}\n"
|
||||||
|
"{: >18}PNG: {}".format(16, 16, '', 24, '', False)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
}.items())
|
||||||
|
def test_ico(filename, metadata):
|
||||||
|
with open(tutils.test_data.path(filename), 'rb') as f:
|
||||||
|
assert metadata == image_parser.parse_ico(f.read())
|
||||||
|
@ -9,8 +9,7 @@ def test_view_image():
|
|||||||
"mitmproxy/data/image.png",
|
"mitmproxy/data/image.png",
|
||||||
"mitmproxy/data/image.gif",
|
"mitmproxy/data/image.gif",
|
||||||
"mitmproxy/data/all.jpeg",
|
"mitmproxy/data/all.jpeg",
|
||||||
# https://bugs.python.org/issue21574
|
"mitmproxy/data/image.ico",
|
||||||
# "mitmproxy/data/image.ico",
|
|
||||||
]:
|
]:
|
||||||
with open(tutils.test_data.path(img), "rb") as f:
|
with open(tutils.test_data.path(img), "rb") as f:
|
||||||
viewname, lines = v(f.read())
|
viewname, lines = v(f.read())
|
||||||
|
Loading…
Reference in New Issue
Block a user