@@ -1740,8 +1740,8 @@ def test_refresh_page(self):
1740
1740
class AdminRawIdWidgetSeleniumTests (AdminWidgetSeleniumTestCase ):
1741
1741
def setUp (self ):
1742
1742
super ().setUp ()
1743
- Band .objects .create (id = 42 , name = "Bogey Blues" )
1744
- Band .objects .create (id = 98 , name = "Green Potatoes" )
1743
+ self . blues = Band .objects .create (name = "Bogey Blues" )
1744
+ self . potatoes = Band .objects .create (name = "Green Potatoes" )
1745
1745
1746
1746
@screenshot_cases (["desktop_size" , "mobile_size" , "rtl" , "dark" , "high_contrast" ])
1747
1747
def test_ForeignKey (self ):
@@ -1763,23 +1763,23 @@ def test_ForeignKey(self):
1763
1763
self .selenium .find_element (By .ID , "lookup_id_main_band" ).click ()
1764
1764
self .wait_for_and_switch_to_popup ()
1765
1765
link = self .selenium .find_element (By .LINK_TEXT , "Bogey Blues" )
1766
- self .assertIn ("/band/42 /" , link .get_attribute ("href" ))
1766
+ self .assertIn (f "/band/{ self . blues . pk } /" , link .get_attribute ("href" ))
1767
1767
link .click ()
1768
1768
1769
1769
# The field now contains the selected band's id
1770
1770
self .selenium .switch_to .window (main_window )
1771
- self .wait_for_value ("#id_main_band" , "42" )
1771
+ self .wait_for_value ("#id_main_band" , str ( self . blues . pk ) )
1772
1772
1773
1773
# Reopen the popup window and click on another band
1774
1774
self .selenium .find_element (By .ID , "lookup_id_main_band" ).click ()
1775
1775
self .wait_for_and_switch_to_popup ()
1776
1776
link = self .selenium .find_element (By .LINK_TEXT , "Green Potatoes" )
1777
- self .assertIn ("/band/98 /" , link .get_attribute ("href" ))
1777
+ self .assertIn (f "/band/{ self . potatoes . pk } /" , link .get_attribute ("href" ))
1778
1778
link .click ()
1779
1779
1780
1780
# The field now contains the other selected band's id
1781
1781
self .selenium .switch_to .window (main_window )
1782
- self .wait_for_value ("#id_main_band" , "98" )
1782
+ self .wait_for_value ("#id_main_band" , str ( self . potatoes . pk ) )
1783
1783
1784
1784
def test_many_to_many (self ):
1785
1785
from selenium .webdriver .common .by import By
@@ -1810,23 +1810,25 @@ def test_many_to_many(self):
1810
1810
self .selenium .find_element (By .ID , "lookup_id_supporting_bands" ).click ()
1811
1811
self .wait_for_and_switch_to_popup ()
1812
1812
link = self .selenium .find_element (By .LINK_TEXT , "Bogey Blues" )
1813
- self .assertIn ("/band/42 /" , link .get_attribute ("href" ))
1813
+ self .assertIn (f "/band/{ self . blues . pk } /" , link .get_attribute ("href" ))
1814
1814
link .click ()
1815
1815
1816
1816
# The field now contains the selected band's id
1817
1817
self .selenium .switch_to .window (main_window )
1818
- self .wait_for_value ("#id_supporting_bands" , "42" )
1818
+ self .wait_for_value ("#id_supporting_bands" , str ( self . blues . pk ) )
1819
1819
1820
1820
# Reopen the popup window and click on another band
1821
1821
self .selenium .find_element (By .ID , "lookup_id_supporting_bands" ).click ()
1822
1822
self .wait_for_and_switch_to_popup ()
1823
1823
link = self .selenium .find_element (By .LINK_TEXT , "Green Potatoes" )
1824
- self .assertIn ("/band/98 /" , link .get_attribute ("href" ))
1824
+ self .assertIn (f "/band/{ self . potatoes . pk } /" , link .get_attribute ("href" ))
1825
1825
link .click ()
1826
1826
1827
1827
# The field now contains the two selected bands' ids
1828
1828
self .selenium .switch_to .window (main_window )
1829
- self .wait_for_value ("#id_supporting_bands" , "42,98" )
1829
+ self .wait_for_value (
1830
+ "#id_supporting_bands" , f"{ self .blues .pk } ,{ self .potatoes .pk } "
1831
+ )
1830
1832
1831
1833
1832
1834
class RelatedFieldWidgetSeleniumTests (AdminWidgetSeleniumTestCase ):
0 commit comments