mirror of
https://github.com/django-components/django-components.git
synced 2025-08-03 22:08:17 +00:00
Make test suite ignore insignificant differences in HTML and whitespace.
This commit is contained in:
parent
6949dc286f
commit
aa4a3092c8
2 changed files with 10 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
from textwrap import dedent
|
||||
import unittest
|
||||
from django.test import SimpleTestCase
|
||||
from django_components import component
|
||||
from .django_test_setup import * # NOQA
|
||||
|
||||
|
@ -21,23 +21,23 @@ class MultistyleComponent(SimpleComponent):
|
|||
css = {"all": ["style.css", "style2.css"]}
|
||||
js = ["script.js", "script2.js"]
|
||||
|
||||
class ComponentRegistryTest(unittest.TestCase):
|
||||
class ComponentRegistryTest(SimpleTestCase):
|
||||
def test_simple_component(self):
|
||||
comp = SimpleComponent()
|
||||
|
||||
self.assertEqual(comp.render_dependencies(), dedent("""
|
||||
self.assertHTMLEqual(comp.render_dependencies(), dedent("""
|
||||
<link href="style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
""").strip())
|
||||
|
||||
self.assertEqual(comp.render(variable="test"), dedent("""
|
||||
self.assertHTMLEqual(comp.render(variable="test"), dedent("""
|
||||
Variable: <strong>test</strong>
|
||||
""").lstrip())
|
||||
|
||||
def test_component_with_list_of_styles(self):
|
||||
comp = MultistyleComponent()
|
||||
|
||||
self.assertEqual(comp.render_dependencies(), dedent("""
|
||||
self.assertHTMLEqual(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">
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from textwrap import dedent
|
||||
import unittest
|
||||
from django.test import SimpleTestCase
|
||||
from django.template import Template, Context
|
||||
from django_components import component
|
||||
from .django_test_setup import * # NOQA
|
||||
|
@ -17,7 +17,7 @@ class SimpleComponent(component.Component):
|
|||
css = {"all": ["style.css"]}
|
||||
js = ["script.js"]
|
||||
|
||||
class ComponentTemplateTagTest(unittest.TestCase):
|
||||
class ComponentTemplateTagTest(SimpleTestCase):
|
||||
def setUp(self):
|
||||
# NOTE: component.registry is global, so need to clear before each test
|
||||
component.registry._registry = {}
|
||||
|
@ -27,7 +27,7 @@ class ComponentTemplateTagTest(unittest.TestCase):
|
|||
|
||||
template = Template('{% load component_tags %}{% component_dependencies %}')
|
||||
rendered = template.render(Context())
|
||||
self.assertEqual(rendered, dedent("""
|
||||
self.assertHTMLEqual(rendered, dedent("""
|
||||
<link href="style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
""").strip())
|
||||
|
@ -37,7 +37,7 @@ class ComponentTemplateTagTest(unittest.TestCase):
|
|||
|
||||
template = Template('{% load component_tags %}{% component name="test" variable="variable" %}')
|
||||
rendered = template.render(Context({}))
|
||||
self.assertEqual(rendered, "Variable: <strong>variable</strong>\n")
|
||||
self.assertHTMLEqual(rendered, "Variable: <strong>variable</strong>\n")
|
||||
|
||||
def test_multiple_component_dependencies(self):
|
||||
component.registry.register(name="test1", component=SimpleComponent)
|
||||
|
@ -45,7 +45,7 @@ class ComponentTemplateTagTest(unittest.TestCase):
|
|||
|
||||
template = Template('{% load component_tags %}{% component_dependencies %}')
|
||||
rendered = template.render(Context())
|
||||
self.assertEqual(rendered, dedent("""
|
||||
self.assertHTMLEqual(rendered, dedent("""
|
||||
<link href="style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
""").strip())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue