Skip to content
Browse files

Handle unexpected strings properly (bug 826534)

  • Loading branch information...
1 parent aa36f6f commit b07a9935eb3517e4a87120e026ae1bd649d2e4cc @mattbasta committed
Showing with 25 additions and 1 deletion.
  1. +18 −1 appvalidator/testcases/webappbase.py
  2. +7 −0 tests/test_webapp_resources.py
View
19 appvalidator/testcases/webappbase.py
@@ -101,7 +101,11 @@ def generic_http_error():
filename=filename)
return
- request.raw.close()
+ try:
+ request.raw.close()
+ except AttributeError:
+ # Some versions of requests don't support close().
+ pass
if not data:
generic_http_error()
@@ -143,6 +147,12 @@ def generic_http_error():
def test_icon(err, data, url, size):
try:
+ size = int(size)
+ except ValueError:
+ # This is handled elsewhere.
+ return
+
+ try:
icon = Image.open(data)
icon.verify()
except IOError:
@@ -193,6 +203,13 @@ def test_app_resources(err, package):
icon_urls = set()
icons = manifest.get("icons", {}).items()
for icon_size, url in icons:
+
+ try:
+ icon_size = int(icon_size)
+ except ValueError:
+ # There will be an error for this someplace else.
+ continue
+
# Don't test the same icon URL twice.
if url in icon_urls:
continue
View
7 tests/test_webapp_resources.py
@@ -273,6 +273,9 @@ def test_pass(self):
self._test_icon("icon-128.png", 128)
self.assert_silent()
+ self._test_icon("icon-128.png", "128")
+ self.assert_silent()
+
def test_bad_icon(self):
self._test_icon("corrupt.xpi", 128)
self.assert_failed(with_errors=True)
@@ -281,6 +284,10 @@ def test_not_square(self):
self._test_icon("icon-128x64.png", 128)
self.assert_failed(with_errors=True)
+ self.setup_err()
+ self._test_icon("icon-128x64.png", "128")
+ self.assert_failed(with_errors=True)
+
def test_bad_size(self):
self._test_icon("icon-128.png", 256)
self.assert_failed(with_errors=True)

0 comments on commit b07a993

Please sign in to comment.
Something went wrong with that request. Please try again.