Skip to content

Commit 08c4a2e

Browse files
committed
Support python 2.6's string format and django 1.7 for StaticLiveServerTestCase
1 parent ff50bb0 commit 08c4a2e

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/test_javascript.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
except ImportError:
1616
webdriver = None
1717

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+
1925
from django.test.utils import override_settings
2026
from django.utils import timezone
2127
from django.utils.unittest import skipIf, skipUnless
@@ -76,7 +82,7 @@ def test_panel_li_a_click_once(self):
7682
# Verify that the panels parent had the djdt-active class added
7783
trigger_count = self.selenium.execute_script(
7884
"return djdt.jQuery('#djDebugToolbar').find('.djdt-active')"
79-
".find('.{}').length".format(panel_name)
85+
".find('.{0}').length".format(panel_name)
8086
)
8187
self.assertEquals(trigger_count, 1)
8288

@@ -90,7 +96,7 @@ def test_panel_li_a_click_twice(self):
9096
# Verify that the panels parent had the djdt-active class removed
9197
trigger_count = self.selenium.execute_script(
9298
"return djdt.jQuery('#djDebugToolbar').find('.djdt-active')"
93-
".find('.{}').length".format(panel_name)
99+
".find('.{0}').length".format(panel_name)
94100
)
95101
self.assertEquals(trigger_count, 0)
96102
self.assertFalse(panel.is_displayed())
@@ -129,7 +135,7 @@ def test_click_panel_button_checkbox(self):
129135
checkbox = panel_trigger.find_element_by_xpath('..')\
130136
.find_element_by_css_selector("input[type=checkbox]")
131137
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))
133139
cookie = self.selenium.get_cookie(cookie_name)
134140
self.assertIsNone(cookie)
135141
# Click on the checkbox to turn off
@@ -186,11 +192,11 @@ def test_toggle_switch_click(self):
186192
panel = self.selenium.find_element_by_id(panel_name)
187193
toggle_switch = panel.find_element_by_class_name('djToggleSwitch')
188194
id_javascript_selector = (
189-
"return djdt.jQuery('#{}').find('.djToggleSwitch').attr('{}')")
195+
"return djdt.jQuery('#{0}').find('.djToggleSwitch').attr('{1}')")
190196
target_id = self.selenium.execute_script(
191197
id_javascript_selector.format(panel_name, 'data-toggle-id')
192198
)
193-
toggle_class = "djToggleDetails_{}".format(target_id)
199+
toggle_class = "djToggleDetails_{0}".format(target_id)
194200
toggled_element = panel.find_element_by_class_name(toggle_class)
195201
toggled = "djUnselected"
196202
untoggled = "djSelected"
@@ -382,7 +388,7 @@ def test_cookie_get(self):
382388
"domain": domain,
383389
})
384390
actual_value = self.selenium.execute_script(
385-
"return djdt.cookie.get('{}')".format(key)
391+
"return djdt.cookie.get('{0}')".format(key)
386392
)
387393
self.assertEquals(actual_value, value)
388394

@@ -395,8 +401,8 @@ def test_cookie_set(self):
395401
expires_lower_bound = timezone.now().date() + timedelta(days=expires)
396402
expires_upper_bound = expires_lower_bound + timedelta(days=1)
397403
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}'}})"
400406
.format(key, value, path, expires, domain)
401407
)
402408
cookie = self.selenium.get_cookie(key)

0 commit comments

Comments
 (0)