|
@@ -17,8 +17,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
)
|
|
|
self.assertEqual(
|
|
|
str(m),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="https://secure.other.com/path/to/js3"></script>"""
|
|
@@ -38,8 +38,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
m3 = Media(Foo)
|
|
|
self.assertEqual(
|
|
|
str(m3),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="https://secure.other.com/path/to/js3"></script>"""
|
|
@@ -70,8 +70,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
w1 = MyWidget1()
|
|
|
self.assertEqual(
|
|
|
str(w1.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="https://secure.other.com/path/to/js3"></script>"""
|
|
@@ -80,8 +80,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
# Media objects can be interrogated by media type
|
|
|
self.assertEqual(
|
|
|
str(w1.media['css']),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">"""
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">"""
|
|
|
)
|
|
|
|
|
|
self.assertEqual(
|
|
@@ -120,9 +120,9 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
w3 = MyWidget3()
|
|
|
self.assertEqual(
|
|
|
str(w1.media + w2.media + w3.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="/path/to/js4"></script>
|
|
@@ -132,8 +132,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
# media addition hasn't affected the original objects
|
|
|
self.assertEqual(
|
|
|
str(w1.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="https://secure.other.com/path/to/js3"></script>"""
|
|
@@ -148,7 +148,7 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
js = ('/path/to/js1', '/path/to/js1')
|
|
|
|
|
|
w4 = MyWidget4()
|
|
|
- self.assertEqual(str(w4.media), """<link href="/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
+ self.assertEqual(str(w4.media), """<link href="/path/to/css1" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>""")
|
|
|
|
|
|
def test_media_deduplication(self):
|
|
@@ -159,7 +159,7 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
css={'all': ('/path/to/css1', '/path/to/css1')},
|
|
|
js=('/path/to/js1', '/path/to/js1'),
|
|
|
)
|
|
|
- self.assertEqual(str(media), """<link href="/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
+ self.assertEqual(str(media), """<link href="/path/to/css1" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>""")
|
|
|
|
|
|
def test_media_property(self):
|
|
@@ -174,7 +174,7 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
media = property(_media)
|
|
|
|
|
|
w4 = MyWidget4()
|
|
|
- self.assertEqual(str(w4.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet">
|
|
|
+ self.assertEqual(str(w4.media), """<link href="/some/path" media="all" rel="stylesheet">
|
|
|
<script src="/some/js"></script>""")
|
|
|
|
|
|
# Media properties can reference the media of their parents
|
|
@@ -184,8 +184,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
media = property(_media)
|
|
|
|
|
|
w5 = MyWidget5()
|
|
|
- self.assertEqual(str(w5.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/other/path" type="text/css" media="all" rel="stylesheet">
|
|
|
+ self.assertEqual(str(w5.media), """<link href="/some/path" media="all" rel="stylesheet">
|
|
|
+<link href="/other/path" media="all" rel="stylesheet">
|
|
|
<script src="/some/js"></script>
|
|
|
<script src="/other/js"></script>""")
|
|
|
|
|
@@ -207,9 +207,9 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
w6 = MyWidget6()
|
|
|
self.assertEqual(
|
|
|
str(w6.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/other/path" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/other/path" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="/other/js"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
@@ -235,8 +235,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
w7 = MyWidget7()
|
|
|
self.assertEqual(
|
|
|
str(w7.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="https://secure.other.com/path/to/js3"></script>"""
|
|
@@ -253,9 +253,9 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
w8 = MyWidget8()
|
|
|
self.assertEqual(
|
|
|
str(w8.media),
|
|
|
- """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
+<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="/path/to/js4"></script>
|
|
@@ -287,8 +287,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
w9 = MyWidget9()
|
|
|
self.assertEqual(
|
|
|
str(w9.media),
|
|
|
- """<link href="/some/path" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/other/path" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="/some/path" media="all" rel="stylesheet">
|
|
|
+<link href="/other/path" media="all" rel="stylesheet">
|
|
|
<script src="/some/js"></script>
|
|
|
<script src="/other/js"></script>"""
|
|
|
)
|
|
@@ -303,8 +303,8 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
js = ('/path/to/js1', '/path/to/js4')
|
|
|
|
|
|
w10 = MyWidget10()
|
|
|
- self.assertEqual(str(w10.media), """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
+ self.assertEqual(str(w10.media), """<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
+<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="/path/to/js4"></script>""")
|
|
|
|
|
@@ -328,9 +328,9 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
w11 = MyWidget11()
|
|
|
self.assertEqual(
|
|
|
str(w11.media),
|
|
|
- """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
+<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="/path/to/js4"></script>
|
|
@@ -357,9 +357,9 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
w12 = MyWidget12()
|
|
|
self.assertEqual(
|
|
|
str(w12.media),
|
|
|
- """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
+<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="/path/to/js4"></script>"""
|
|
|
)
|
|
@@ -382,10 +382,10 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
multimedia = MultimediaWidget()
|
|
|
self.assertEqual(
|
|
|
str(multimedia.media),
|
|
|
- """<link href="/file4" type="text/css" media="print" rel="stylesheet">
|
|
|
-<link href="/file3" type="text/css" media="screen" rel="stylesheet">
|
|
|
-<link href="/file1" type="text/css" media="screen, print" rel="stylesheet">
|
|
|
-<link href="/file2" type="text/css" media="screen, print" rel="stylesheet">
|
|
|
+ """<link href="/file4" media="print" rel="stylesheet">
|
|
|
+<link href="/file3" media="screen" rel="stylesheet">
|
|
|
+<link href="/file1" media="screen, print" rel="stylesheet">
|
|
|
+<link href="/file2" media="screen, print" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="/path/to/js4"></script>"""
|
|
|
)
|
|
@@ -426,9 +426,9 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
mymulti = MyMultiWidget()
|
|
|
self.assertEqual(
|
|
|
str(mymulti.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="/path/to/js4"></script>
|
|
@@ -468,9 +468,9 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
f1 = MyForm()
|
|
|
self.assertEqual(
|
|
|
str(f1.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="/path/to/js4"></script>
|
|
@@ -483,9 +483,9 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
f2 = AnotherForm()
|
|
|
self.assertEqual(
|
|
|
str(f1.media + f2.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="/path/to/js4"></script>
|
|
@@ -505,10 +505,10 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
f3 = FormWithMedia()
|
|
|
self.assertEqual(
|
|
|
str(f3.media),
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/some/form/css" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/some/form/css" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css3" media="all" rel="stylesheet">
|
|
|
<script src="/path/to/js1"></script>
|
|
|
<script src="/some/form/javascript"></script>
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
@@ -524,10 +524,10 @@ class FormsMediaTestCase(SimpleTestCase):
|
|
|
<script src="http://media.other.com/path/to/js2"></script>
|
|
|
<script src="/path/to/js4"></script>
|
|
|
<script src="https://secure.other.com/path/to/js3"></script>"""
|
|
|
- """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/some/form/css" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
|
|
|
-<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">"""
|
|
|
+ """<link href="http://media.example.com/static/path/to/css1" media="all" rel="stylesheet">
|
|
|
+<link href="/some/form/css" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css2" media="all" rel="stylesheet">
|
|
|
+<link href="/path/to/css3" media="all" rel="stylesheet">"""
|
|
|
)
|
|
|
|
|
|
def test_html_safe(self):
|