@@ -894,33 +894,38 @@ def test_get_next_record_with_excluded_field(self):
894
894
895
895
896
896
class CreateHistoryModelTests (unittest .TestCase ):
897
+ @staticmethod
898
+ def create_history_model (model , inherited ):
899
+ custom_model_name_prefix = "MockHistorical"
900
+ records = HistoricalRecords (
901
+ # Provide a custom history model name, to prevent name collisions
902
+ # with existing historical models
903
+ custom_model_name = lambda name : f"{ custom_model_name_prefix } { name } " ,
904
+ )
905
+ records .module = model .__module__
906
+ return records .create_history_model (model , inherited )
907
+
897
908
def test_create_history_model_with_one_to_one_field_to_integer_field (self ):
898
- records = HistoricalRecords ()
899
- records .module = AdminProfile .__module__
900
909
try :
901
- records .create_history_model (AdminProfile , False )
910
+ self .create_history_model (AdminProfile , False )
902
911
except Exception :
903
912
self .fail (
904
913
"SimpleHistory should handle foreign keys to one to one"
905
914
"fields to integer fields without throwing an exception"
906
915
)
907
916
908
917
def test_create_history_model_with_one_to_one_field_to_char_field (self ):
909
- records = HistoricalRecords ()
910
- records .module = Bookcase .__module__
911
918
try :
912
- records .create_history_model (Bookcase , False )
919
+ self .create_history_model (Bookcase , False )
913
920
except Exception :
914
921
self .fail (
915
922
"SimpleHistory should handle foreign keys to one to one"
916
923
"fields to char fields without throwing an exception."
917
924
)
918
925
919
926
def test_create_history_model_with_multiple_one_to_ones (self ):
920
- records = HistoricalRecords ()
921
- records .module = MultiOneToOne .__module__
922
927
try :
923
- records .create_history_model (MultiOneToOne , False )
928
+ self .create_history_model (MultiOneToOne , False )
924
929
except Exception :
925
930
self .fail (
926
931
"SimpleHistory should handle foreign keys to one to one"
0 commit comments