Ignore type="text/css" in tests, it doesn't matter.

This commit is contained in:
Emil Stenström 2022-12-25 23:00:59 +01:00
parent 8ebe65d31e
commit 8af63ad3ad
3 changed files with 33 additions and 31 deletions

View file

@ -41,7 +41,7 @@ class ComponentTest(SimpleTestCase):
comp.render_dependencies(),
dedent(
"""
<link href="style.css" type="text/css" media="all" rel="stylesheet">
<link href="style.css" media="all" rel="stylesheet">
<script src="script.js"></script>
"""
).strip(),
@ -68,8 +68,8 @@ class ComponentTest(SimpleTestCase):
comp.render_dependencies(),
dedent(
"""
<link href="style.css" type="text/css" media="all" rel="stylesheet">
<link href="style2.css" type="text/css" media="all" rel="stylesheet">
<link href="style.css" media="all" rel="stylesheet">
<link href="style2.css" media="all" rel="stylesheet">
<script src="script.js"></script>
<script src="script2.js"></script>
"""
@ -143,7 +143,7 @@ class ComponentMediaTests(SimpleTestCase):
comp.render_dependencies(),
dedent(
"""\
<link href="path/to/style.css" type="text/css" media="all" rel="stylesheet">
<link href="path/to/style.css" media="all" rel="stylesheet">
<script src="path/to/script.js"></script>
"""
),
@ -160,8 +160,8 @@ class ComponentMediaTests(SimpleTestCase):
comp.render_dependencies(),
dedent(
"""\
<link href="path/to/style.css" type="text/css" media="all" rel="stylesheet">
<link href="path/to/style2.css" type="text/css" media="all" rel="stylesheet">
<link href="path/to/style.css" media="all" rel="stylesheet">
<link href="path/to/style2.css" media="all" rel="stylesheet">
<script src="path/to/script.js"></script>
"""
),
@ -182,9 +182,9 @@ class ComponentMediaTests(SimpleTestCase):
comp.render_dependencies(),
dedent(
"""\
<link href="path/to/style.css" type="text/css" media="all" rel="stylesheet">
<link href="path/to/style2.css" type="text/css" media="print" rel="stylesheet">
<link href="path/to/style3.css" type="text/css" media="screen" rel="stylesheet">
<link href="path/to/style.css" media="all" rel="stylesheet">
<link href="path/to/style2.css" media="print" rel="stylesheet">
<link href="path/to/style3.css" media="screen" rel="stylesheet">
<script src="path/to/script.js"></script>
"""
),
@ -201,7 +201,7 @@ class ComponentMediaTests(SimpleTestCase):
comp.render_dependencies(),
dedent(
"""\
<link href="path/to/style.css" type="text/css" media="all" rel="stylesheet">
<link href="path/to/style.css" media="all" rel="stylesheet">
<script src="path/to/script.js"></script>
"""
),

View file

@ -54,7 +54,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=0)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=0,
)
@ -76,7 +76,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=0,
)
@ -90,7 +90,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=1)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
@ -112,7 +112,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
@ -126,7 +126,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
@ -141,7 +141,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
@ -175,7 +175,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
@ -201,12 +201,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
self.assertInHTML('<script src="script.js">', rendered, count=1)
self.assertInHTML('<script src="script2.js">', rendered, count=1)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
self.assertInHTML(
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style2.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
@ -222,12 +222,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
self.assertInHTML('<script src="script.js">', rendered, count=1)
self.assertInHTML('<script src="script2.js">', rendered, count=1)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=0,
)
self.assertInHTML(
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style2.css" media="all" rel="stylesheet"/>',
rendered,
count=0,
)
@ -243,12 +243,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
self.assertInHTML('<script src="script.js">', rendered, count=0)
self.assertInHTML('<script src="script2.js">', rendered, count=0)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
self.assertInHTML(
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style2.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
@ -266,12 +266,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
self.assertInHTML('<script src="script.js">', rendered, count=0)
self.assertInHTML('<script src="script2.js">', rendered, count=0)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=0,
)
self.assertInHTML(
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style2.css" media="all" rel="stylesheet"/>',
rendered,
count=0,
)
@ -288,12 +288,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
self.assertInHTML(
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style2.css" media="all" rel="stylesheet"/>',
rendered,
count=0,
)
@ -326,12 +326,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
self.assertInHTML('<script src="script.js">', rendered, count=0)
self.assertInHTML('<script src="script2.js">', rendered, count=1)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=0,
)
self.assertInHTML(
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style2.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
@ -354,12 +354,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
self.assertInHTML('<script src="script.js">', rendered, count=1)
self.assertInHTML('<script src="script2.js">', rendered, count=1)
self.assertInHTML(
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)
self.assertInHTML(
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
'<link href="style2.css" media="all" rel="stylesheet"/>',
rendered,
count=1,
)

View file

@ -16,12 +16,14 @@ middleware = ComponentDependencyMiddleware(
class Django30CompatibleSimpleTestCase(SimpleTestCase):
def assertHTMLEqual(self, left, right):
left = left.replace(' type="text/javascript"', "")
left = left.replace(' type="text/css"', "")
super(Django30CompatibleSimpleTestCase, self).assertHTMLEqual(
left, right
)
def assertInHTML(self, needle, haystack, count=None, msg_prefix=""):
haystack = haystack.replace(' type="text/javascript"', "")
haystack = haystack.replace(' type="text/css"', "")
super().assertInHTML(needle, haystack, count, msg_prefix)