Render spaceless HTML
This commit is contained in:
parent
d59565fa82
commit
7226ca57a2
2 changed files with 12 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
{% spaceless %}
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
@ -40,4 +41,5 @@
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
{% endspaceless %}
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
from django.template import Context, Template
|
||||||
from django.test import Client
|
from django.test import Client
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
|
@ -48,7 +49,15 @@ def _assert_article_is_rendered(item: Article, res):
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
content = res.content.decode("utf-8")
|
content = res.content.decode("utf-8")
|
||||||
assert item.title in content
|
assert item.title in content
|
||||||
assert item.get_formatted_content in content
|
html = item.get_formatted_content
|
||||||
|
html = get_spaceless_html(html)
|
||||||
|
assert html in content
|
||||||
|
|
||||||
|
|
||||||
|
def get_spaceless_html(html):
|
||||||
|
context = Context({})
|
||||||
|
html = Template("{% spaceless %}" + html + "{% endspaceless %}").render(context)
|
||||||
|
return html
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|
Reference in a new issue