1
1
import pytest
2
- from pathlib import Path
3
2
from bs4 import BeautifulSoup as Soup # type: ignore
4
3
from jupyter_book_to_htmlbook .figure_processing import (
5
4
process_figures ,
@@ -47,7 +46,7 @@ def test_simple_figure_case(self):
47
46
<a class="headerlink" href="#example-fig" title="Permalink to this image">#</a>
48
47
</p></figcaption>"""
49
48
chapter = Soup (text , 'html.parser' )
50
- result = process_figures (chapter , Path ( 'example' ) )
49
+ result = process_figures (chapter )
51
50
assert not result .find ("figcaption" ).find ("a" , class_ = "headerlink" )
52
51
assert result .find ("img" ).get ("style" ) is None
53
52
assert not result .find ("span" , class_ = "caption-number" )
@@ -66,7 +65,7 @@ def test_markdown_figure_case(self):
66
65
<a class="headerlink" href="#markdown-fig" title="Permalink to this image">
67
66
#</a></p></figcaption></figure>"""
68
67
chapter = Soup (text , 'html.parser' )
69
- result = process_figures (chapter , Path ( 'example' ) )
68
+ result = process_figures (chapter )
70
69
assert not result .find ("figcaption" ).find ("a" , class_ = "headerlink" )
71
70
assert result .find ("img" ).get ("style" ) is None
72
71
assert not result .find ("span" , class_ = "caption-number" )
@@ -76,7 +75,7 @@ def test_markdown_image(self):
76
75
""" support bare markdown images, i.e., informal figs """
77
76
text = '<p><img alt="Flower" src="../_images/flower.png" /></p>'
78
77
chapter = Soup (text , 'html.parser' )
79
- result = process_informal_figs (chapter , Path ( 'example' ) )
78
+ result = process_informal_figs (chapter )
80
79
assert str (result ) == (
81
80
'<figure class="informal"><img alt="Flower" ' +
82
81
'src="../_images/flower.png"/></figure>' )
@@ -88,7 +87,7 @@ def test_myst_image(self):
88
87
'e-class align-center" src="_images/flower.png" style="' + \
89
88
'width: 249px; height: 150px;" /></a>'
90
89
chapter = Soup (text , 'html.parser' )
91
- result = process_informal_figs (chapter , Path ( 'example' ) )
90
+ result = process_informal_figs (chapter )
92
91
assert str (result ) == (
93
92
'<figure class="informal"><img alt="flower" ' +
94
93
'src="_images/flower.png"/></figure>' )
@@ -109,7 +108,7 @@ def test_extra_p_tags_and_spaces_are_removed_from_captions(self):
109
108
<a class="headerlink" href="#example-fig" title="Permalink to this image">#</a>
110
109
</p></figcaption>"""
111
110
chapter = Soup (text , 'html.parser' )
112
- result = process_figures (chapter , Path ( 'example' ) )
111
+ result = process_figures (chapter )
113
112
caption = result .find ("figcaption" )
114
113
assert not caption .p
115
114
assert "\n " not in caption .string
@@ -130,7 +129,7 @@ def test_markup_is_preserved_in_captions(self):
130
129
<a class="headerlink" href="#example-fig" title="Permalink to this image">#</a>
131
130
</p></figcaption>"""
132
131
chapter = Soup (text , 'html.parser' )
133
- result = process_figures (chapter , Path ( 'example' ) )
132
+ result = process_figures (chapter )
134
133
caption = result .find ("figcaption" )
135
134
assert not caption .p
136
135
assert caption .find ("code" )
@@ -152,7 +151,7 @@ def test_markup_is_preserved_in_captions_at_beginning(self):
152
151
<a class="headerlink" href="#example-fig" title="Permalink to this image">#</a>
153
152
</p></figcaption>"""
154
153
chapter = Soup (text , 'html.parser' )
155
- result = process_figures (chapter , Path ( 'example' ) )
154
+ result = process_figures (chapter )
156
155
caption = result .find ("figcaption" )
157
156
assert caption .find ("strong" )
158
157
assert caption .find ("em" )
@@ -175,7 +174,7 @@ def test_no_anchor_wrap(self):
175
174
<a class="headerlink" href="#markdown-fig" title="Permalink to this image">
176
175
#</a></p></figcaption></figure>"""
177
176
chapter = Soup (text , 'html.parser' )
178
- result = process_figures (chapter , Path ( 'example' ) )
177
+ result = process_figures (chapter )
179
178
assert result .find ("figcaption" )
180
179
assert not result .find ("figcaption" ).find ("a" , class_ = "headerlink" )
181
180
assert result .find ("img" ).get ("style" ) is None
@@ -197,7 +196,7 @@ def test_no_caption_number(self):
197
196
<a class="headerlink" href="#example-fig" title="Permalink to this image">#</a>
198
197
</p></figcaption>"""
199
198
chapter = Soup (text , 'html.parser' )
200
- result = process_figures (chapter , Path ( 'example' ) )
199
+ result = process_figures (chapter )
201
200
assert result .find ("figcaption" )
202
201
assert not result .find ("figcaption" ).find ("a" , class_ = "headerlink" )
203
202
assert result .find ("img" ).get ("style" ) is None
@@ -217,7 +216,7 @@ def test_generated_figure_processing(self, code_generated_figure):
217
216
"""
218
217
Minimal generated figure test
219
218
"""
220
- result = process_figures (code_generated_figure , "" )
219
+ result = process_figures (code_generated_figure )
221
220
assert result .find ("figure" ).get ("id" ) == "code-output-fig"
222
221
assert result .find ("figcaption" )
223
222
assert not result .find ("figcaption" ).find ("a" , class_ = "headerlink" )
0 commit comments