@@ -9,7 +9,7 @@ def test_skip_ablog_templates_but_missing_templates(app: Sphinx):
9
9
"""Completely override the templates used by ablog, but not provide them."""
10
10
with pytest .raises (
11
11
ThemeError ,
12
- match = r"An error happened in rendering the page blog/archive \.\nReason: TemplateNotFound\(\"'ablog/catalog.html' not found in *." ,
12
+ match = r"An error happened in rendering the page blog/author \.\nReason: TemplateNotFound\(\"'ablog/catalog.html' not found in *." ,
13
13
):
14
14
app .build ()
15
15
@@ -20,37 +20,55 @@ def test_skip_ablog_templates_but_missing_templates(app: Sphinx):
20
20
confoverrides = {
21
21
"templates_path" : ["_templates" ],
22
22
"skip_injecting_base_ablog_templates" : False , # default value
23
- "html_sidebars" : {"**" : ["ablog/postcard.html" ]},
23
+ "html_sidebars" : {
24
+ "**" : [
25
+ # overriden by user
26
+ "ablog/postcard.html" ,
27
+ # fallback to builtin
28
+ "ablog/authors.html" ,
29
+ ]
30
+ },
24
31
},
25
32
)
26
33
def test_override_template_but_fallback_missing (app : Sphinx , rootdir : Path ):
27
34
"""Partically override the only some Ablog templates, but use the Ablog ones for missing as fallback."""
28
35
app .build ()
29
36
30
- # read the content of custom postcard template
31
- expected = (rootdir / "test-templates" / "_templates" / "ablog" / "postcard.html" ).read_text ()
32
-
33
- # is it in the output?
37
+ # is the customized template it in the output?
38
+ customized = (rootdir / "test-templates" / "_templates" / "ablog" / "postcard.html" ).read_text ()
34
39
source = (app .outdir / "post.html" ).read_text ()
35
- assert expected in source
40
+ assert customized in source
41
+
42
+ # is builtin template in the output?
43
+ builtin = '<div class="ablog-sidebar-item ablog__authors">'
44
+ assert builtin in source
36
45
37
46
38
47
@pytest .mark .sphinx (
39
48
"html" ,
40
49
testroot = "templates" ,
41
50
confoverrides = {
42
- "html_sidebars" : {"**" : ["ablog/postcard.html" ]},
51
+ "html_sidebars" : {
52
+ "**" : [
53
+ # overriden by theme
54
+ "ablog/postcard.html" ,
55
+ # fallback to builtin
56
+ "ablog/authors.html" ,
57
+ ]
58
+ },
43
59
"html_theme_path" : "_themes" ,
44
60
"html_theme" : "test_theme" ,
45
61
},
46
62
)
47
63
def test_themes_templates_come_first (app : Sphinx , rootdir : Path ):
48
- """Ensures that if theme supplies own Ablog template, it is used over the builtin one."""
64
+ """Ensures that if theme supplies own Ablog template, it is used over the builtin one, but fallback to builtin for missing ones ."""
49
65
app .build ()
50
66
51
- # read the content of custom postcard template
52
- expected = (rootdir / "test-templates" / "_themes" / "test_theme" / "ablog" / "postcard.html" ).read_text ()
53
-
54
- # is it in the output?
67
+ # is the customized template it in the output?
68
+ customized = (rootdir / "test-templates" / "_themes" / "test_theme" / "ablog" / "postcard.html" ).read_text ()
55
69
source = (app .outdir / "post.html" ).read_text ()
56
- assert expected in source
70
+ assert customized in source
71
+
72
+ # is builtin template in the output?
73
+ builtin = '<div class="ablog-sidebar-item ablog__authors">'
74
+ assert builtin in source
0 commit comments