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>
|
||||
<html lang="en">
|
||||
{% spaceless %}
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
@ -40,4 +41,5 @@
|
|||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
{% endspaceless %}
|
||||
</html>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
from django.template import Context, Template
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
from model_bakery import baker
|
||||
|
@ -48,7 +49,15 @@ def _assert_article_is_rendered(item: Article, res):
|
|||
assert res.status_code == 200
|
||||
content = res.content.decode("utf-8")
|
||||
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
|
||||
|
|
Reference in a new issue