@@ -341,9 +341,10 @@ def test_save_load_fast_slow(self):
341341 }
342342 dict_fast_0 = {key : dict_fast_0 [key ] for key in set (dict_fast_0 ) & set (dict_fast_1 )}
343343 dict_fast_1 = {key : dict_fast_1 [key ] for key in set (dict_fast_0 ) & set (dict_fast_1 )}
344- # check that all additional keys are None, except for `default_to_square` and `data_format` which are only set in fast processors
344+ # Fast processors filter None values from to_dict(), so differences should only be special keys
345345 self .assertTrue (
346- all (value is None for key , value in difference .items () if key not in ["default_to_square" , "data_format" ])
346+ all (key in ["default_to_square" , "data_format" ] for key in difference .keys ()),
347+ f"Fast processors should only differ in special keys, found: { list (difference .keys ())} " ,
347348 )
348349 # check that the remaining keys are the same
349350 self .assertEqual (dict_fast_0 , dict_fast_1 )
@@ -391,9 +392,10 @@ def test_save_load_fast_slow_auto(self):
391392 }
392393 dict_fast_0 = {key : dict_fast_0 [key ] for key in set (dict_fast_0 ) & set (dict_fast_1 )}
393394 dict_fast_1 = {key : dict_fast_1 [key ] for key in set (dict_fast_0 ) & set (dict_fast_1 )}
394- # check that all additional keys are None, except for `default_to_square` and `data_format` which are only set in fast processors
395+ # Fast processors filter None values from to_dict(), so differences should only be special keys
395396 self .assertTrue (
396- all (value is None for key , value in difference .items () if key not in ["default_to_square" , "data_format" ])
397+ all (key in ["default_to_square" , "data_format" ] for key in difference .keys ()),
398+ f"Fast processors should only differ in special keys, found: { list (difference .keys ())} " ,
397399 )
398400 # check that the remaining keys are the same
399401 self .assertEqual (dict_fast_0 , dict_fast_1 )
@@ -693,6 +695,17 @@ def _is_old_model_by_commit_date(model_type, date_cutoff=(2025, 9, 1)):
693695 f"a fast image processor implementation. Please implement the corresponding fast processor." ,
694696 )
695697
698+ def test_fast_image_processor_to_dict_no_none_values (self ):
699+ """Test that fast image processors don't include None values in to_dict() output."""
700+ if self .fast_image_processing_class is None :
701+ self .skipTest ("Skipping test as fast image processor is not defined" )
702+
703+ image_processor = self .fast_image_processing_class (** self .image_processor_dict )
704+ processor_dict = image_processor .to_dict ()
705+
706+ none_values = [k for k , v in processor_dict .items () if v is None ]
707+ self .assertEqual (len (none_values ), 0 , f"Found None values in to_dict(): { none_values } " )
708+
696709
697710class AnnotationFormatTestMixin :
698711 # this mixin adds a test to assert that usages of the
0 commit comments