@@ -455,6 +455,7 @@ def test_history_form_view_without_getting_history(self):
455
455
admin .history_form_view (request , poll .id , history .pk )
456
456
457
457
context = {
458
+ ** admin_site .each_context (request ),
458
459
# Verify this is set for original object
459
460
"original" : poll ,
460
461
"change_history" : False ,
@@ -484,7 +485,10 @@ def test_history_form_view_without_getting_history(self):
484
485
"save_on_top" : admin .save_on_top ,
485
486
"root_path" : getattr (admin_site , "root_path" , None ),
486
487
}
487
- context .update (admin_site .each_context (request ))
488
+ # This key didn't exist prior to Django 4.2
489
+ if "log_entries" in context :
490
+ context ["log_entries" ] = ANY
491
+
488
492
mock_render .assert_called_once_with (
489
493
request , admin .object_history_form_template , context
490
494
)
@@ -509,6 +513,7 @@ def test_history_form_view_getting_history(self):
509
513
admin .history_form_view (request , poll .id , history .pk )
510
514
511
515
context = {
516
+ ** admin_site .each_context (request ),
512
517
# Verify this is set for history object not poll object
513
518
"original" : history .instance ,
514
519
"change_history" : True ,
@@ -538,7 +543,10 @@ def test_history_form_view_getting_history(self):
538
543
"save_on_top" : admin .save_on_top ,
539
544
"root_path" : getattr (admin_site , "root_path" , None ),
540
545
}
541
- context .update (admin_site .each_context (request ))
546
+ # This key didn't exist prior to Django 4.2
547
+ if "log_entries" in context :
548
+ context ["log_entries" ] = ANY
549
+
542
550
mock_render .assert_called_once_with (
543
551
request , admin .object_history_form_template , context
544
552
)
@@ -563,6 +571,7 @@ def test_history_form_view_getting_history_with_setting_off(self):
563
571
admin .history_form_view (request , poll .id , history .pk )
564
572
565
573
context = {
574
+ ** admin_site .each_context (request ),
566
575
# Verify this is set for history object not poll object
567
576
"original" : poll ,
568
577
"change_history" : False ,
@@ -592,7 +601,10 @@ def test_history_form_view_getting_history_with_setting_off(self):
592
601
"save_on_top" : admin .save_on_top ,
593
602
"root_path" : getattr (admin_site , "root_path" , None ),
594
603
}
595
- context .update (admin_site .each_context (request ))
604
+ # This key didn't exist prior to Django 4.2
605
+ if "log_entries" in context :
606
+ context ["log_entries" ] = ANY
607
+
596
608
mock_render .assert_called_once_with (
597
609
request , admin .object_history_form_template , context
598
610
)
@@ -617,6 +629,7 @@ def test_history_form_view_getting_history_abstract_external(self):
617
629
admin .history_form_view (request , obj .id , history .pk )
618
630
619
631
context = {
632
+ ** admin_site .each_context (request ),
620
633
# Verify this is set for history object
621
634
"original" : history .instance ,
622
635
"change_history" : True ,
@@ -648,7 +661,10 @@ def test_history_form_view_getting_history_abstract_external(self):
648
661
"save_on_top" : admin .save_on_top ,
649
662
"root_path" : getattr (admin_site , "root_path" , None ),
650
663
}
651
- context .update (admin_site .each_context (request ))
664
+ # This key didn't exist prior to Django 4.2
665
+ if "log_entries" in context :
666
+ context ["log_entries" ] = ANY
667
+
652
668
mock_render .assert_called_once_with (
653
669
request , admin .object_history_form_template , context
654
670
)
@@ -676,6 +692,7 @@ def test_history_form_view_accepts_additional_context(self):
676
692
)
677
693
678
694
context = {
695
+ ** admin_site .each_context (request ),
679
696
# Verify this is set for original object
680
697
"anything_else" : "will be merged into context" ,
681
698
"original" : poll ,
@@ -706,7 +723,10 @@ def test_history_form_view_accepts_additional_context(self):
706
723
"save_on_top" : admin .save_on_top ,
707
724
"root_path" : getattr (admin_site , "root_path" , None ),
708
725
}
709
- context .update (admin_site .each_context (request ))
726
+ # This key didn't exist prior to Django 4.2
727
+ if "log_entries" in context :
728
+ context ["log_entries" ] = ANY
729
+
710
730
mock_render .assert_called_once_with (
711
731
request , admin .object_history_form_template , context
712
732
)
0 commit comments