diff --git a/appvalidator/testcases/webappbase.py b/appvalidator/testcases/webappbase.py index 3f4bced..7b16014 100644 --- a/appvalidator/testcases/webappbase.py +++ b/appvalidator/testcases/webappbase.py @@ -101,7 +101,11 @@ def try_get_resource(err, package, url, filename, resource_type="URL", 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() @@ -142,6 +146,12 @@ def try_get_resource(err, package, url, filename, resource_type="URL", 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() @@ -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 diff --git a/tests/test_webapp_resources.py b/tests/test_webapp_resources.py index 14e143c..274c3e5 100644 --- a/tests/test_webapp_resources.py +++ b/tests/test_webapp_resources.py @@ -273,6 +273,9 @@ class TestIconProperties(TestCase): 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 @@ class TestIconProperties(TestCase): 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)