From 6e19e9fe8f714e84166a6428a3c7a32ef4c96c43 Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Sat, 13 May 2023 03:28:52 +0900 Subject: [PATCH] fix: Render str types not bytes --- src/atsphinx/og_article/processors.py | 2 +- tests/test_it.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/atsphinx/og_article/processors.py b/src/atsphinx/og_article/processors.py index 78448d9..8c809f1 100644 --- a/src/atsphinx/og_article/processors.py +++ b/src/atsphinx/og_article/processors.py @@ -53,5 +53,5 @@ def add_metatags( ) for tag in node["tags"] ] - metatags = b"\n".join([ET.tostring(e) for e in metatags]) + metatags = b"\n".join([ET.tostring(e) for e in metatags]).decode() context["metatags"] += f"\n{metatags}" diff --git a/tests/test_it.py b/tests/test_it.py index a64e53f..a4b7c88 100644 --- a/tests/test_it.py +++ b/tests/test_it.py @@ -1,7 +1,9 @@ """Standard tests.""" from io import StringIO +from pathlib import Path import pytest +from bs4 import BeautifulSoup from sphinx.testing.util import SphinxTestApp from atsphinx.og_article import models @@ -10,8 +12,12 @@ @pytest.mark.sphinx("html") def test__it(app: SphinxTestApp, status: StringIO, warning: StringIO): """Test to pass.""" - app.builder.read() + app.build() doctree = app.env.get_doctree("index") assert doctree is not None target_nodes = list(doctree.findall(models.og_article)) assert len(target_nodes) == 1 + soup = BeautifulSoup(Path(f"{app.outdir}/index.html").read_text(), "html.parser") + assert soup.find("meta", {"property": "article:published_time"}) + assert soup.find("meta", {"property": "article:modified_time"}) + assert "b'" not in str(soup)