Skip to content

Commit 26980ed

Browse files
committed
lint
1 parent 501a818 commit 26980ed

2 files changed

Lines changed: 37 additions & 27 deletions

File tree

plone/namedfile/test.pt

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
i18n:name=""
4343
i18n:translate=""
4444
>picture tags</a>,
45-
<a href="#srcset" i18n="name" i18n:translate="">img tag with srcset</a>,
45+
<a href="#srcset"
46+
i18n="name"
47+
i18n:translate=""
48+
>img tag with srcset</a>,
4649
<a href="#stored"
4750
i18n:name=""
4851
i18n:translate=""
@@ -199,23 +202,25 @@
199202
</p>
200203
</section>
201204

202-
<section class="section" id="srcset">
203-
<h2 i18n:translate="">img with srcset attributes</h2>
204-
<p i18n:translate="">
205+
<section class="section"
206+
id="srcset"
207+
>
208+
<h2 i18n:translate="">img with srcset attributes</h2>
209+
<p i18n:translate="">
205210
srcst allows the browser selecting the correct image depending on the space the image has on a page.
206-
</p>
207-
<p i18n:translate="">
208-
To do so, the @@images view provides a srcset method, that will output the full srcset of this image, using all available image scales. It has a required paramter the value of the sizes attribute that the user of this method has to provide and will be outputed as is in the generated HTML.
209-
</p>
210-
<p>
211-
<img tal:replace="structure python:images.srcset('image', sizes='(min-width: 1400px) 550px, 90vw')" />
212-
</p>
213-
<p>
214-
<code>
215-
<img tal:replace="python:images.srcset('image', sizes='(min-width: 1400px) 550px, 90vw')" />
216-
</code>
217-
</p>
218-
</section>
211+
</p>
212+
<p i18n:translate="">
213+
To do so, the @@images view provides a srcset method, that will output the full srcset of this image, using all available image scales. It has a required parameter the value of the sizes attribute that the user of this method has to provide and will be outputted as is in the generated HTML.
214+
</p>
215+
<p>
216+
<img tal:replace="structure python:images.srcset('image', sizes='(min-width: 1400px) 550px, 90vw')" />
217+
</p>
218+
<p>
219+
<code>
220+
<img tal:replace="python:images.srcset('image', sizes='(min-width: 1400px) 550px, 90vw')" />
221+
</code>
222+
</p>
223+
</section>
219224

220225
<section class="section"
221226
id="stored"

plone/namedfile/tests/test_scaling.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def testOversizedHighPixelDensityScale(self):
814814
self.assertEqual(foo.srcset[0]["scale"], 2)
815815

816816
def testImgSrcSet(self):
817-
""" test rendered srcset values """
817+
"""test rendered srcset values"""
818818
self.scaling.available_sizes = {
819819
"huge": (1600, 65536),
820820
"great": (1200, 65536),
@@ -828,16 +828,13 @@ def testImgSrcSet(self):
828828
"icon": (32, 32),
829829
"listing": (16, 16),
830830
}
831-
tag = self.scaling.srcset(
832-
"image",
833-
sizes="50vw"
834-
)
831+
tag = self.scaling.srcset("image", sizes="50vw")
835832
base = self.item.absolute_url()
836833
expected = f"""<img title="foo" sizes="50vw" srcset="{base}/@@images/image-200-....png 200w, {base}/@@images/image-128-....png 128w, {base}/@@images/image-64-....png 64w, {base}/@@images/image-32-....png 32w, {base}/@@images/image-16-....png 16w" src="{base}/@@images/image-1600-....png".../>"""
837834
self.assertTrue(_ellipsis_match(expected, tag.strip()))
838835

839836
def testImgSrcSetCustomSrc(self):
840-
""" test that we can select a custom scale in the src attribute """
837+
"""test that we can select a custom scale in the src attribute"""
841838
self.scaling.available_sizes = {
842839
"huge": (1600, 65536),
843840
"great": (1200, 65536),
@@ -858,7 +855,7 @@ def testImgSrcSetCustomSrc(self):
858855

859856
def testImgSrcSetInexistentScale(self):
860857
"""test that when requesting an inexistent scale for the src attribute
861-
we provide the biggest scale we can produce
858+
we provide the biggest scale we can produce
862859
"""
863860
self.scaling.available_sizes = {
864861
"huge": (1600, 65536),
@@ -873,7 +870,9 @@ def testImgSrcSetInexistentScale(self):
873870
"icon": (32, 32),
874871
"listing": (16, 16),
875872
}
876-
tag = self.scaling.srcset("image", sizes="50vw", scale_in_src="inexistent-scale-name")
873+
tag = self.scaling.srcset(
874+
"image", sizes="50vw", scale_in_src="inexistent-scale-name"
875+
)
877876
base = self.item.absolute_url()
878877
expected = f"""<img title="foo" sizes="50vw" srcset="{base}/@@images/image-200-....png 200w, {base}/@@images/image-128-....png 128w, {base}/@@images/image-64-....png 64w, {base}/@@images/image-32-....png 32w, {base}/@@images/image-16-....png 16w" src="{base}/@@images/image-200-....png".../>"""
879878
self.assertTrue(_ellipsis_match(expected, tag.strip()))
@@ -899,7 +898,7 @@ def testImgSrcSetCustomTitle(self):
899898
self.assertTrue(_ellipsis_match(expected, tag.strip()))
900899

901900
def testImgSrcSetAdditionalAttributes(self):
902-
"""test that additional parameters are outputed as is, like alt, loading, ..."""
901+
"""test that additional parameters are outputted as is, like alt, loading, ..."""
903902
self.scaling.available_sizes = {
904903
"huge": (1600, 65536),
905904
"great": (1200, 65536),
@@ -913,7 +912,13 @@ def testImgSrcSetAdditionalAttributes(self):
913912
"icon": (32, 32),
914913
"listing": (16, 16),
915914
}
916-
tag = self.scaling.srcset("image", sizes="50vw", title="My Custom Title", alt="This image shows nothing", loading="lazy")
915+
tag = self.scaling.srcset(
916+
"image",
917+
sizes="50vw",
918+
title="My Custom Title",
919+
alt="This image shows nothing",
920+
loading="lazy",
921+
)
917922
base = self.item.absolute_url()
918923
expected = f"""<img title="My Custom Title" alt="This image shows nothing" loading="lazy" sizes="50vw" srcset="{base}/@@images/image-200-....png 200w, {base}/@@images/image-128-....png 128w, {base}/@@images/image-64-....png 64w, {base}/@@images/image-32-....png 32w, {base}/@@images/image-16-....png 16w" src="{base}/@@images/image-1600-....png".../>"""
919924
self.assertTrue(_ellipsis_match(expected, tag.strip()))

0 commit comments

Comments
 (0)