diff options
Diffstat (limited to 'tests/test_json.py')
-rw-r--r-- | tests/test_json.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/test_json.py b/tests/test_json.py index a83ef0a24..82a2a3d07 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -1,10 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from urllib import urlencode -from urllib2 import urlopen, HTTPError -from json import loads +import urllib +import urllib2 +from json import loads from logging import log url = "http://localhost:8001/api/%s" @@ -15,25 +15,25 @@ class TestJson(object): def call(self, name, post=None): if not post: post = {} post['session'] = self.key - u = urlopen(url % name, data=urlencode(post)) + u = urllib2.urlopen(url % name, data=urlencode(post)) return loads(u.read()) def setUp(self): - u = urlopen(url % "login", data=urlencode({"username": "TestUser", "password": "pwhere"})) + u = urllib2.urlopen(url % "login", data=urlencode({"username": "TestUser", "password": "pwhere"})) self.key = loads(u.read()) assert self.key is not False def test_wronglogin(self): - u = urlopen(url % "login", data=urlencode({"username": "crap", "password": "wrongpw"})) + u = urllib2.urlopen(url % "login", data=urlencode({"username": "crap", "password": "wrongpw"})) assert loads(u.read()) is False def test_access(self): try: - urlopen(url % "getServerVersion") - except HTTPError, e: + urllib2.urlopen(url % "getServerVersion") + except urllib2.HTTPError, e: assert e.code == 403 else: assert False @@ -49,7 +49,7 @@ class TestJson(object): def test_unknown_method(self): try: self.call("notExisting") - except HTTPError, e: + except urllib2.HTTPError, e: assert e.code == 404 else: assert False |