def get_csv(self):
# Call the URL, get the response, parse it strictly as CSV,
# and return the list of dictionaries
rsp = self.client.get(self.url)
self.assertEqual(200, rsp.status_code)
dialect = csv.excel()
dialect.strict = True
reader = csv.DictReader(StringIO(rsp.content), dialect=dialect)
result = []
for item in reader:
for k, v in item.iteritems():
item[k] = v.decode('utf-8')
result.append(item)
return result
评论列表
文章目录