Skip to content

Commit

Permalink
unitest-restful: handle text type correctly across Python 2/3
Browse files Browse the repository at this point in the history
In short, this is unicode in Python 2 and str in Python 3.
  • Loading branch information
asergi committed Sep 24, 2015
1 parent 2bc0d42 commit e5263a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion unitest-restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

import requests

try:
text_type = str
except NameError:
text_type = unicode

SERVER_PORT = 61234
URL = "http://localhost:%s/api/2" % SERVER_PORT
pid = None
Expand Down Expand Up @@ -91,7 +96,7 @@ def test_003_plugins(self):
req = requests.get("%s/%s" % (URL, p))
self.assertTrue(req.ok)
if p in ('uptime', 'now'):
self.assertIsInstance(req.json(), unicode)
self.assertIsInstance(req.json(), text_type)
elif p in ('fs', 'monitor', 'percpu', 'sensors', 'alert', 'processlist',
'diskio', 'hddtemp', 'batpercent', 'network'):
self.assertIsInstance(req.json(), list)
Expand Down

0 comments on commit e5263a8

Please sign in to comment.