summaryrefslogtreecommitdiffstats
path: root/unitest-restful.py
diff options
context:
space:
mode:
authorAlessio Sergi <al3hex@gmail.com>2015-09-24 11:29:39 +0200
committerAlessio Sergi <al3hex@gmail.com>2015-09-24 11:29:39 +0200
commite5263a8ad0542c477806096740b0ad5a14dec195 (patch)
tree1b1c1bff91b128483b5212f3e6d1c2f8e7776d30 /unitest-restful.py
parent2bc0d427367839a97406514d71261ab216131c67 (diff)
unitest-restful: handle text type correctly across Python 2/3
In short, this is unicode in Python 2 and str in Python 3.
Diffstat (limited to 'unitest-restful.py')
-rwxr-xr-xunitest-restful.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/unitest-restful.py b/unitest-restful.py
index aebde904..d1b2a51e 100755
--- a/unitest-restful.py
+++ b/unitest-restful.py
@@ -29,6 +29,11 @@ from glances.core.glances_globals import version
import requests
+try:
+ text_type = str
+except NameError:
+ text_type = unicode
+
SERVER_PORT = 61234
URL = "http://localhost:%s/api/2" % SERVER_PORT
pid = None
@@ -91,7 +96,7 @@ class TestGlances(unittest.TestCase):
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)