15
15
except ImportError :
16
16
webdriver = None
17
17
18
- from django .test import LiveServerTestCase
18
+ try :
19
+ from django .contrib .staticfiles .testing import StaticLiveServerTestCase \
20
+ as LiveServerTestCase
21
+ except ImportError :
22
+ # When we're using < Django 1.7
23
+ from django .test import LiveServerTestCase
24
+
19
25
from django .test .utils import override_settings
20
26
from django .utils import timezone
21
27
from django .utils .unittest import skipIf , skipUnless
@@ -76,7 +82,7 @@ def test_panel_li_a_click_once(self):
76
82
# Verify that the panels parent had the djdt-active class added
77
83
trigger_count = self .selenium .execute_script (
78
84
"return djdt.jQuery('#djDebugToolbar').find('.djdt-active')"
79
- ".find('.{}').length" .format (panel_name )
85
+ ".find('.{0 }').length" .format (panel_name )
80
86
)
81
87
self .assertEquals (trigger_count , 1 )
82
88
@@ -90,7 +96,7 @@ def test_panel_li_a_click_twice(self):
90
96
# Verify that the panels parent had the djdt-active class removed
91
97
trigger_count = self .selenium .execute_script (
92
98
"return djdt.jQuery('#djDebugToolbar').find('.djdt-active')"
93
- ".find('.{}').length" .format (panel_name )
99
+ ".find('.{0 }').length" .format (panel_name )
94
100
)
95
101
self .assertEquals (trigger_count , 0 )
96
102
self .assertFalse (panel .is_displayed ())
@@ -129,7 +135,7 @@ def test_click_panel_button_checkbox(self):
129
135
checkbox = panel_trigger .find_element_by_xpath ('..' )\
130
136
.find_element_by_css_selector ("input[type=checkbox]" )
131
137
cookie_name = checkbox .get_attribute ("data-cookie" )
132
- self .assertEquals (cookie_name , "djdt{}" .format (panel_name ))
138
+ self .assertEquals (cookie_name , "djdt{0 }" .format (panel_name ))
133
139
cookie = self .selenium .get_cookie (cookie_name )
134
140
self .assertIsNone (cookie )
135
141
# Click on the checkbox to turn off
@@ -186,11 +192,11 @@ def test_toggle_switch_click(self):
186
192
panel = self .selenium .find_element_by_id (panel_name )
187
193
toggle_switch = panel .find_element_by_class_name ('djToggleSwitch' )
188
194
id_javascript_selector = (
189
- "return djdt.jQuery('#{}').find('.djToggleSwitch').attr('{}')" )
195
+ "return djdt.jQuery('#{0 }').find('.djToggleSwitch').attr('{1 }')" )
190
196
target_id = self .selenium .execute_script (
191
197
id_javascript_selector .format (panel_name , 'data-toggle-id' )
192
198
)
193
- toggle_class = "djToggleDetails_{}" .format (target_id )
199
+ toggle_class = "djToggleDetails_{0 }" .format (target_id )
194
200
toggled_element = panel .find_element_by_class_name (toggle_class )
195
201
toggled = "djUnselected"
196
202
untoggled = "djSelected"
@@ -382,7 +388,7 @@ def test_cookie_get(self):
382
388
"domain" : domain ,
383
389
})
384
390
actual_value = self .selenium .execute_script (
385
- "return djdt.cookie.get('{}')" .format (key )
391
+ "return djdt.cookie.get('{0 }')" .format (key )
386
392
)
387
393
self .assertEquals (actual_value , value )
388
394
@@ -395,8 +401,8 @@ def test_cookie_set(self):
395
401
expires_lower_bound = timezone .now ().date () + timedelta (days = expires )
396
402
expires_upper_bound = expires_lower_bound + timedelta (days = 1 )
397
403
self .selenium .execute_script (
398
- "djdt.cookie.set('{}','{}',"
399
- "{{'path':'{}','expires':{},'domain':'{}'}})"
404
+ "djdt.cookie.set('{0 }','{1 }',"
405
+ "{{'path':'{2 }','expires':{3 },'domain':'{4 }'}})"
400
406
.format (key , value , path , expires , domain )
401
407
)
402
408
cookie = self .selenium .get_cookie (key )
0 commit comments