@@ -68,8 +68,15 @@ def get_src_dst(
68
68
jpg_image : pathlib .Path | None = None ,
69
69
gif_image : pathlib .Path | None = None ,
70
70
webp_image : pathlib .Path | None = None ,
71
+ svg_image : pathlib .Path | None = None ,
71
72
) -> tuple [pathlib .Path , pathlib .Path ]:
72
- options = {"png" : png_image , "jpg" : jpg_image , "webp" : webp_image , "gif" : gif_image }
73
+ options = {
74
+ "png" : png_image ,
75
+ "jpg" : jpg_image ,
76
+ "webp" : webp_image ,
77
+ "gif" : gif_image ,
78
+ "svg" : svg_image ,
79
+ }
73
80
if fmt not in options :
74
81
raise LookupError (f"Unsupported fmt passed: { fmt } " )
75
82
src = options [fmt ]
@@ -616,10 +623,10 @@ def test_ensure_matches(webp_image):
616
623
617
624
@pytest .mark .parametrize (
618
625
"fmt,expected" ,
619
- [("png" , "PNG" ), ("jpg" , "JPEG" ), ("gif" , "GIF" ), ("webp" , "WEBP" )],
626
+ [("png" , "PNG" ), ("jpg" , "JPEG" ), ("gif" , "GIF" ), ("webp" , "WEBP" ), ( "svg" , "SVG" ) ],
620
627
)
621
628
def test_format_for_real_images_suffix (
622
- png_image , jpg_image , gif_image , webp_image , tmp_path , fmt , expected
629
+ png_image , jpg_image , gif_image , webp_image , svg_image , tmp_path , fmt , expected
623
630
):
624
631
src , _ = get_src_dst (
625
632
tmp_path ,
@@ -628,16 +635,17 @@ def test_format_for_real_images_suffix(
628
635
jpg_image = jpg_image ,
629
636
gif_image = gif_image ,
630
637
webp_image = webp_image ,
638
+ svg_image = svg_image ,
631
639
)
632
640
assert format_for (src ) == expected
633
641
634
642
635
643
@pytest .mark .parametrize (
636
644
"fmt,expected" ,
637
- [("png" , "PNG" ), ("jpg" , "JPEG" ), ("gif" , "GIF" ), ("webp" , "WEBP" )],
645
+ [("png" , "PNG" ), ("jpg" , "JPEG" ), ("gif" , "GIF" ), ("webp" , "WEBP" ), ( "svg" , "SVG" ) ],
638
646
)
639
647
def test_format_for_real_images_content_path (
640
- png_image , jpg_image , gif_image , webp_image , tmp_path , fmt , expected
648
+ png_image , jpg_image , gif_image , webp_image , svg_image , tmp_path , fmt , expected
641
649
):
642
650
src , _ = get_src_dst (
643
651
tmp_path ,
@@ -646,16 +654,17 @@ def test_format_for_real_images_content_path(
646
654
jpg_image = jpg_image ,
647
655
gif_image = gif_image ,
648
656
webp_image = webp_image ,
657
+ svg_image = svg_image ,
649
658
)
650
659
assert format_for (src , from_suffix = False ) == expected
651
660
652
661
653
662
@pytest .mark .parametrize (
654
663
"fmt,expected" ,
655
- [("png" , "PNG" ), ("jpg" , "JPEG" ), ("gif" , "GIF" ), ("webp" , "WEBP" )],
664
+ [("png" , "PNG" ), ("jpg" , "JPEG" ), ("gif" , "GIF" ), ("webp" , "WEBP" ), ( "svg" , "SVG" ) ],
656
665
)
657
666
def test_format_for_real_images_content_bytes (
658
- png_image , jpg_image , gif_image , webp_image , tmp_path , fmt , expected
667
+ png_image , jpg_image , gif_image , webp_image , svg_image , tmp_path , fmt , expected
659
668
):
660
669
src , _ = get_src_dst (
661
670
tmp_path ,
@@ -664,6 +673,7 @@ def test_format_for_real_images_content_bytes(
664
673
jpg_image = jpg_image ,
665
674
gif_image = gif_image ,
666
675
webp_image = webp_image ,
676
+ svg_image = svg_image ,
667
677
)
668
678
assert format_for (io .BytesIO (src .read_bytes ()), from_suffix = False ) == expected
669
679
@@ -675,6 +685,7 @@ def test_format_for_real_images_content_bytes(
675
685
("image.jpg" , "JPEG" ),
676
686
("image.gif" , "GIF" ),
677
687
("image.webp" , "WEBP" ),
688
+ ("image.svg" , "SVG" ),
678
689
("image.raster" , None ),
679
690
],
680
691
)
0 commit comments