diff options
| author | 2015-05-12 02:17:30 +0200 | |
|---|---|---|
| committer | 2015-05-12 03:22:32 +0200 | |
| commit | 000426c9d890ba2a71625a7454f9c573f10b9bae (patch) | |
| tree | 8fa66da5061b850778f72f84038d9bb8bfa31f2f /tests | |
| parent | 'from os' -> 'import os' and so on... (diff) | |
| download | pyload-000426c9d890ba2a71625a7454f9c573f10b9bae.tar.xz | |
'from time' -> 'import time' and so on...
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/APIExerciser.py | 8 | ||||
| -rw-r--r-- | tests/test_json.py | 18 | 
2 files changed, 13 insertions, 13 deletions
diff --git a/tests/APIExerciser.py b/tests/APIExerciser.py index 25eb666d7..02bfef20d 100644 --- a/tests/APIExerciser.py +++ b/tests/APIExerciser.py @@ -7,10 +7,10 @@ import gc  import random  import string  import threading +import time  import traceback  from math import floor -from time import time  from pyload.remote.thriftbackend.ThriftClient import ThriftClient, Destination @@ -48,7 +48,7 @@ class APIExerciser(threading.Thread):          self.setDaemon(True)          self.core = core          self.count = 0  #: number of methods -        self.time = time() +        self.time = time.time()          self.api = ThriftClient(user=user, password=pw) if thrift else core.api @@ -84,11 +84,11 @@ class APIExerciser(threading.Thread):                  if not sumCalled % 1000:  #: not thread safe                      self.core.log.info("Exercisers tested %d api calls" % sumCalled) -                    persec = sumCalled / (time() - self.time) +                    persec = sumCalled / (time.time() - self.time)                      self.core.log.info("Approx. %.2f calls per second." % persec)                      self.core.log.info("Approx. %.2f ms per call." % (1000 / persec))                      self.core.log.info("Collected garbage: %d" % gc.collect()) -                    # sleep(random() / 500) +                    # time.sleep(random() / 500)      def testAPI(self): 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  | 
