@@ -121,30 +121,36 @@ def test_render_styled_with_mask(mask):
121121
122122
123123def test_embedded_image_and_error_correction (tmp_path ):
124- "If an embedded image is specified, error correction must be the highest so the QR code is readable"
124+ "If an embedded image is specified, error correction should be the highest so the QR code is readable"
125125 tmpfile = str (tmp_path / "test.png" )
126126 embedded_img = Image .new ("RGB" , (10 , 10 ), color = "red" )
127127 embedded_img .save (tmpfile )
128128
129129 qr = qrcode .QRCode (error_correction = qrcode .ERROR_CORRECT_L )
130130 qr .add_data (UNICODE_TEXT )
131- with pytest .raises (ValueError ):
131+
132+ message = (
133+ "Low error correction level with an embedded image might lead to unreadable QR codes. "
134+ "Use ERROR_CORRECT_H for better results."
135+ )
136+
137+ with pytest .warns (match = message ):
132138 qr .make_image (embedded_image_path = tmpfile )
133- with pytest .raises ( ValueError ):
139+ with pytest .warns ( match = message ):
134140 qr .make_image (embedded_image = embedded_img )
135141
136142 qr = qrcode .QRCode (error_correction = qrcode .ERROR_CORRECT_M )
137143 qr .add_data (UNICODE_TEXT )
138- with pytest .raises ( ValueError ):
144+ with pytest .warns ( match = message ):
139145 qr .make_image (embedded_image_path = tmpfile )
140- with pytest .raises ( ValueError ):
146+ with pytest .warns ( match = message ):
141147 qr .make_image (embedded_image = embedded_img )
142148
143149 qr = qrcode .QRCode (error_correction = qrcode .ERROR_CORRECT_Q )
144150 qr .add_data (UNICODE_TEXT )
145- with pytest .raises ( ValueError ):
151+ with pytest .warns ( match = message ):
146152 qr .make_image (embedded_image_path = tmpfile )
147- with pytest .raises ( ValueError ):
153+ with pytest .warns ( match = message ):
148154 qr .make_image (embedded_image = embedded_img )
149155
150156 # The only accepted correction level when an embedded image is provided
0 commit comments