diff options
author | Alessio Sergi <al3hex@gmail.com> | 2015-09-24 11:29:39 +0200 |
---|---|---|
committer | Alessio Sergi <al3hex@gmail.com> | 2015-09-24 11:29:39 +0200 |
commit | e5263a8ad0542c477806096740b0ad5a14dec195 (patch) | |
tree | 1b1c1bff91b128483b5212f3e6d1c2f8e7776d30 /unitest-restful.py | |
parent | 2bc0d427367839a97406514d71261ab216131c67 (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-x | unitest-restful.py | 7 |
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) |