Permalink
Browse files

Don't use PIL to validate images

  • Loading branch information...
1 parent f13050a commit 421f2f88f53b4b2038e1e9f0f5ac47e82eb439ca @nkuttler nkuttler committed Feb 19, 2013
Showing with 5 additions and 11 deletions.
  1. +0 −1 .travis.yml
  2. +5 −10 piwikapi/tests/analytics.py
View
@@ -11,7 +11,6 @@ env:
- secure: "KxjYYynxnUYfFZizglKs4IqTkVN3rQEujcwFUF71Vf4BnoFtnIw3sKmTW1e5\npq3VyU9GuxpW63L36uTT401DmkOdtdaEUYSH6Yra1362CGbSXHQwzVyjDwT9\n2q+3zXgHDOn+oaTRrN7z5wiVwzlyMuhCi2H1Tle2TWU+5Oaa8oI="
- secure: "d63KPgn5i10RMJOODfGMKKpk9xeqJPUFO9504CQFKgcdGIHEvlHAWQMc7sNe\nvdrARzgi8QpDiu9QQsCezBBUvWfqo+BPSib6LePvKx7wyjXWhj24ukjGeLDG\nGJtETOk3Wd3ucjrX2RLAs5pW5RyP2qui6g+7GfpU0I/UvvC+CXQ="
install:
- - pip install -q --use-mirrors PIL
# 2.5 misses json
- if [[ $TRAVIS_PYTHON_VERSION == '2.5' ]]; then pip install -q --use-mirrors simplejson; fi
# 2.6 doesn't support assertRegexpMatches etc.
@@ -1,5 +1,4 @@
-from PIL import Image
-from StringIO import StringIO
+import imghdr
try:
import json
except ImportError:
@@ -58,14 +57,10 @@ def test_get_imagegraph(self):
self.a.set_parameter('apiAction', 'getCountry')
self.a.set_parameter('token_auth', self.settings['PIWIK_TOKEN_AUTH'])
r = self.a.send_request()
- try:
- im = Image.open(StringIO(r))
- got_image = True
- except:
- got_image = False
- self.assertTrue(
- got_image,
- "Couldn't get an ImageGraph"
+ self.assertEqual(
+ 'png',
+ imghdr.what(None, r),
+ "Couldn't get a PNG ImageGraph"
)
def test_remove_parameter(self):

0 comments on commit 421f2f8

Please sign in to comment.