##// END OF EJS Templates
Fix lint errors
Pete Blois -
Show More
@@ -801,9 +801,20 b' class Image(DisplayObject):'
801 801 _FMT_GIF: 'image/gif',
802 802 }
803 803
804 def __init__(self, data=None, url=None, filename=None, format=None,
805 embed=None, width=None, height=None, retina=False,
806 unconfined=False, metadata=None, alt=None):
804 def __init__(
805 self,
806 data=None,
807 url=None,
808 filename=None,
809 format=None,
810 embed=None,
811 width=None,
812 height=None,
813 retina=False,
814 unconfined=False,
815 metadata=None,
816 alt=None,
817 ):
807 818 """Create a PNG/JPEG/GIF image object given raw data.
808 819
809 820 When this object is returned by an input cell or passed to the
@@ -937,8 +948,8 b' class Image(DisplayObject):'
937 948 if self.height is None and self.metadata.get('height', {}):
938 949 self.height = metadata['height']
939 950
940 if self.alt is None and self.metadata.get('alt', {}):
941 self.alt = metadata['alt']
951 if self.alt is None and self.metadata.get("alt", {}):
952 self.alt = metadata["alt"]
942 953
943 954 if retina:
944 955 self._retina_shape()
@@ -969,7 +980,7 b' class Image(DisplayObject):'
969 980
970 981 def _repr_html_(self):
971 982 if not self.embed:
972 width = height = klass = alt = ''
983 width = height = klass = alt = ""
973 984 if self.width:
974 985 width = ' width="%d"' % self.width
975 986 if self.height:
@@ -978,7 +989,7 b' class Image(DisplayObject):'
978 989 klass = ' class="unconfined"'
979 990 if self.alt:
980 991 alt = ' alt="%s"' % html.escape(self.alt)
981 return u'<img src="{url}"{width}{height}{klass}{alt}/>'.format(
992 return '<img src="{url}"{width}{height}{klass}{alt}/>'.format(
982 993 url=self.url,
983 994 width=width,
984 995 height=height,
@@ -1017,7 +1028,7 b' class Image(DisplayObject):'
1017 1028 if self.unconfined:
1018 1029 md['unconfined'] = self.unconfined
1019 1030 if self.alt:
1020 md['alt'] = self.alt
1031 md["alt"] = self.alt
1021 1032 if md or always_both:
1022 1033 return b64_data, md
1023 1034 else:
@@ -94,9 +94,9 b' def test_embed_svg_url():'
94 94
95 95 if args[0] == url:
96 96 return MockResponse(svg_data)
97 elif args[0] == url + 'z':
98 ret= MockResponse(gzip_svg)
99 ret.headers['content-encoding']= 'gzip'
97 elif args[0] == url + "z":
98 ret = MockResponse(gzip_svg)
99 ret.headers["content-encoding"] = "gzip"
100 100 return ret
101 101 return MockResponse(None)
102 102
@@ -459,19 +459,24 b' def test_display_handle():'
459 459
460 460 def test_image_alt_tag():
461 461 """Simple test for display.Image(args, alt=x,)"""
462 thisurl = 'http://example.com/image.png'
463 img = display.Image(url=thisurl, alt='an image')
462 thisurl = "http://example.com/image.png"
463 img = display.Image(url=thisurl, alt="an image")
464 464 nt.assert_equal(u'<img src="%s" alt="an image"/>' % (thisurl), img._repr_html_())
465 img = display.Image(url=thisurl, unconfined=True, alt='an image')
466 nt.assert_equal(u'<img src="%s" class="unconfined" alt="an image"/>' % (thisurl), img._repr_html_())
465 img = display.Image(url=thisurl, unconfined=True, alt="an image")
466 nt.assert_equal(
467 u'<img src="%s" class="unconfined" alt="an image"/>' % (thisurl),
468 img._repr_html_(),
469 )
467 470 img = display.Image(url=thisurl, alt='>"& <')
468 nt.assert_equal(u'<img src="%s" alt="&gt;&quot;&amp; &lt;"/>' % (thisurl), img._repr_html_())
471 nt.assert_equal(
472 u'<img src="%s" alt="&gt;&quot;&amp; &lt;"/>' % (thisurl), img._repr_html_()
473 )
469 474
470 img = display.Image(url=thisurl, metadata={'alt':'an image'})
471 nt.assert_equal(img.alt, 'an image')
475 img = display.Image(url=thisurl, metadata={"alt": "an image"})
476 nt.assert_equal(img.alt, "an image")
472 477
473 478 here = os.path.dirname(__file__)
474 img = display.Image(os.path.join(here, "2x2.png"), alt='an image')
475 nt.assert_equal(img.alt, 'an image')
479 img = display.Image(os.path.join(here, "2x2.png"), alt="an image")
480 nt.assert_equal(img.alt, "an image")
476 481 _, md = img._repr_png_()
477 nt.assert_equal(md['alt'], 'an image')
482 nt.assert_equal(md["alt"], "an image")
General Comments 0
You need to be logged in to leave comments. Login now