changeset 8:7b6bec689805

forgot to use a file-like object as urlopen's return value
author Atul Varma <varmaa@toolness.com>
date Thu, 31 Dec 2009 14:19:09 -0800
parents 98f1da3b585c
children 9d6306907982
files test.py whoisi_cache.py
diffstat 2 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test.py	Thu Dec 31 13:33:28 2009 -0800
+++ b/test.py	Thu Dec 31 14:19:09 2009 -0800
@@ -1,4 +1,5 @@
 import unittest
+import StringIO
 from copy import deepcopy
 
 import whoisi_cache
@@ -36,7 +37,7 @@
                                                 urlopen=self.fake_open)
 
     def fake_open(self, url):
-        return json.dumps(self.urls[url])
+        return StringIO.StringIO(json.dumps(self.urls[url]))
 
     def testGetMaxPersonIDWorks(self):
         self.urls = {
--- a/whoisi_cache.py	Thu Dec 31 13:33:28 2009 -0800
+++ b/whoisi_cache.py	Thu Dec 31 14:19:09 2009 -0800
@@ -28,7 +28,7 @@
         full_url = "%sapi/%s?%s" % (self.url, name,
                                     urllib.urlencode(query_args))
         logging.debug('retrieving %s' % full_url)
-        return json.loads(self._urlopen(full_url))
+        return json.loads(self._urlopen(full_url).read())
 
     def get_person(self, app, person):
         return self._call_api_method('getPerson',