Updated testscripts

This commit is contained in:
jpirnay
2026-04-06 12:06:21 +02:00
parent db7d5af56b
commit 22267f038a
6 changed files with 26 additions and 58 deletions
+26 -58
View File
@@ -1007,37 +1007,6 @@ def main():
)
print("Creating layout regression test EPUB...")
layout_css = """
<style>
body { line-height: 1.25; }
p { margin-top: 0.7em; margin-bottom: 0.7em; }
.note { font-size: 0.9em; }
.c1 { margin-left: 24px; }
.c2 { margin-left: 48px; }
.c3 { margin-left: 12px; }
.c4 { margin-left: 12px; }
.v1 { margin-top: 1.6em; margin-bottom: 1.6em; }
.v2 { margin-top: 1.2em; margin-bottom: 1.2em; }
.v3 { margin-top: 0.8em; margin-bottom: 0.8em; }
.image-shell {
margin-top: 1.4em;
margin-bottom: 1.4em;
margin-left: 60px;
margin-right: 60px;
}
.image-shell img { width: 100%; }
.image-shell-tight {
margin-top: 1.4em;
margin-bottom: 1.4em;
}
.image-shell-tight p { margin-top: 0; margin-bottom: 0; }
.hidden-image {
margin-top: 1.4em;
margin-bottom: 1.4em;
}
.hidden-image img { display: none; }
</style>
"""
layout_chapters = [
(
@@ -1046,7 +1015,8 @@ p { margin-top: 0.7em; margin-bottom: 0.7em; }
"Layout Regression Tests",
"""
<p>This EPUB exercises recent parser edge cases around nested block styles and image wrappers.</p>
<p><strong>Recommended settings:</strong> Embedded Style ON, Paragraph Alignment set to Book Style or Justify.</p>
<p><strong>Recommended settings:</strong> Paragraph Alignment set to Book Style or Justify.</p>
<p>This regression EPUB uses inline style attributes rather than a head &lt;style&gt; block so it works even if chapter-local embedded CSS is not loaded.</p>
<ul>
<li>Nested horizontal margin inheritance for sibling blocks</li>
<li>Vertical paragraph spacing should not explode with nested wrappers</li>
@@ -1062,17 +1032,18 @@ p { margin-top: 0.7em; margin-bottom: 0.7em; }
make_chapter(
"Nested Horizontal Margin Inheritance",
"""
<p class="note">This chapter mirrors the c1/c2/c3/c4 example behind PR 1582.</p>
<p class="note">Expected: the first paragraph is visibly more indented than the second, but both still inherit the outer wrapper indentation.</p>
<div class="c1">
<div class="c2">
<p class="c3">C3 paragraph. This text should have the largest left indent because it inherits c1, c2, and c3. Repeat text to make the paragraph wrap across multiple lines and make the effective left inset obvious while reading.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">This chapter mirrors the c1/c2/c3/c4 example behind PR 1582.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Expected: C3 is indented the most. C4 is indented less than C3, but still more than the baseline paragraph outside the wrapper.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Expected order of indentation: C3 &gt; C4 &gt; baseline paragraph.</p>
<div style="margin-left: 24px;">
<div style="margin-left: 48px;">
<p style="margin-top: 0.7em; margin-bottom: 0.7em; margin-left: 12px;">C3 paragraph. This text should have the largest left indent because it inherits the outer wrapper, the inner wrapper, and its own left margin. Repeat text to make the paragraph wrap across multiple lines and make the effective left inset obvious while reading.</p>
</div>
<p class="c4">C4 paragraph. This text should still inherit the outer c1 indent, but not the inner c2 indent. It should therefore appear less indented than the paragraph above, not flush with the body text.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em; margin-left: 12px;">C4 paragraph. This text should still inherit the outer wrapper indent, but not the inner wrapper indent. It should therefore appear less indented than the paragraph above, not flush with the body text.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Outer-wrapper-only control paragraph. This paragraph should still be indented relative to the page body because it inherits the outer wrapper margin, even though it has no paragraph-level margin-left of its own.</p>
</div>
<p>Reference paragraph outside the wrappers. This paragraph should align with the normal body text and helps compare the wrapper indentation against the baseline.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Baseline paragraph outside the wrappers. This paragraph should align with the normal body text and should be the least indented paragraph on this page.</p>
""",
head_content=layout_css,
),
[],
),
@@ -1081,16 +1052,15 @@ p { margin-top: 0.7em; margin-bottom: 0.7em; }
make_chapter(
"Nested Vertical Margin Sanity",
"""
<p class="note">Expected: wrapper nesting should not create an oversized blank vertical gulf between these paragraphs.</p>
<div class="v1">
<div class="v2">
<p class="v3">Nested vertical spacing paragraph. There should be some breathing room above and below, but not dramatically more than a normal section break.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Expected: wrapper nesting should not create an oversized blank vertical gulf between these paragraphs.</p>
<div style="margin-top: 1.6em; margin-bottom: 1.6em;">
<div style="margin-top: 1.2em; margin-bottom: 1.2em;">
<p style="margin-top: 0.8em; margin-bottom: 0.8em;">Nested vertical spacing paragraph. There should be some breathing room above and below, but not dramatically more than a normal section break.</p>
</div>
<p class="v3">Sibling paragraph after the nested block. Spacing before this paragraph should feel normal and should not keep growing with every ancestor wrapper.</p>
<p style="margin-top: 0.8em; margin-bottom: 0.8em;">Sibling paragraph after the nested block. Spacing before this paragraph should feel normal and should not keep growing with every ancestor wrapper.</p>
</div>
<p>Baseline paragraph after the wrapper section. This should not be pushed far down the page.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Baseline paragraph after the wrapper section. This should not be pushed far down the page.</p>
""",
head_content=layout_css,
),
[],
),
@@ -1099,15 +1069,14 @@ p { margin-top: 0.7em; margin-bottom: 0.7em; }
make_chapter(
"Image Wrapper Spacing",
"""
<p class="note">Expected: the wrapper's margins should create space around the image, and the paragraph after the image should start with normal spacing rather than inheriting a second copy of that gap.</p>
<div class="image-shell-tight">
<div class="image-shell">
<p><img src="images/centering_test.jpg" alt="Wrapped image spacing test"/></p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Expected: the wrapper's margins should create space around the image, and the paragraph after the image should start with normal spacing rather than inheriting a second copy of that gap.</p>
<div style="margin-top: 1.4em; margin-bottom: 1.4em;">
<div style="margin-top: 1.4em; margin-bottom: 1.4em; margin-left: 60px; margin-right: 60px;">
<p style="margin-top: 0; margin-bottom: 0;"><img src="images/centering_test.jpg" alt="Wrapped image spacing test" style="width: 100%;"/></p>
</div>
</div>
<p>Paragraph after wrapped image. If the wrapper spacing leaks, this paragraph will begin too far down the page. If container width is ignored, the image may also appear too wide for the wrapper.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Paragraph after wrapped image. If the wrapper spacing leaks, this paragraph will begin too far down the page. If container width is ignored, the image may also appear too wide for the wrapper.</p>
""",
head_content=layout_css,
),
[("centering_test.jpg", images["centering_test.jpg"])],
),
@@ -1116,13 +1085,12 @@ p { margin-top: 0.7em; margin-bottom: 0.7em; }
make_chapter(
"Hidden Image Spacing Reset",
"""
<p class="note">Expected: the hidden image wrapper should not leave a large blank gap before the following paragraph.</p>
<div class="hidden-image">
<p><img src="images/centering_test.jpg" alt="This image is intentionally hidden by CSS"/></p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Expected: the hidden image wrapper should not leave a large blank gap before the following paragraph.</p>
<div style="margin-top: 1.4em; margin-bottom: 1.4em;">
<p style="margin-top: 0; margin-bottom: 0;"><img src="images/centering_test.jpg" alt="This image is intentionally hidden by CSS" style="display: none;"/></p>
</div>
<p>Paragraph after hidden image. This should follow with near-normal spacing, not the large gap that would be appropriate for a visible wrapped image.</p>
<p style="margin-top: 0.7em; margin-bottom: 0.7em;">Paragraph after hidden image. This should follow with near-normal spacing, not the large gap that would be appropriate for a visible wrapped image.</p>
""",
head_content=layout_css,
),
[("centering_test.jpg", images["centering_test.jpg"])],
),