File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,20 @@ def test_make_image_with_wrong_pattern():
106106 qrcode .QRCode (mask_pattern = 42 )
107107
108108
109+ def test_best_mask_pattern_includes_format_info ():
110+ """Mask evaluation should use the complete symbol per ISO 18004 §7.8.3.1."""
111+ qr = qrcode .QRCode (error_correction = qrcode .constants .ERROR_CORRECT_H )
112+ qr .add_data ("hello" )
113+ qr .best_fit ()
114+ qr .data_cache = qrcode .util .create_data (
115+ qr .version , qr .error_correction , qr .data_list
116+ )
117+ # The old code zeroed out format info, version info, and the dark module
118+ # during mask evaluation, which violated the spec and selected mask 5 for
119+ # this input. With the complete symbol evaluated, the correct mask is 6.
120+ assert qr .best_mask_pattern () == 6
121+
122+
109123def test_mask_pattern_setter ():
110124 qr = qrcode .QRCode ()
111125
You can’t perform that action at this time.
0 commit comments