summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/APIExerciser.py58
-rw-r--r--tests/clonedigger.sh2
-rw-r--r--tests/code_analysis.sh2
-rw-r--r--tests/test_api.py2
4 files changed, 33 insertions, 31 deletions
diff --git a/tests/APIExerciser.py b/tests/APIExerciser.py
index d17f81ae2..f4b082479 100644
--- a/tests/APIExerciser.py
+++ b/tests/APIExerciser.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import with_statement
+
import string
from threading import Thread
from random import choice, sample, randint
@@ -15,7 +17,7 @@ from pyload.remote.thriftbackend.ThriftClient import ThriftClient, Destination
def createURLs():
""" create some urls, some may fail """
urls = []
- for x in range(0, randint(20, 100)):
+ for x in xrange(0, randint(20, 100)):
name = "DEBUG_API"
if randint(0, 5) == 5:
name = "" #: this link will fail
@@ -32,7 +34,7 @@ sumCalled = 0
def startApiExerciser(core, n):
- for _i in range(n):
+ for _i in xrange(n):
APIExerciser(core).start()
@@ -60,32 +62,32 @@ class APIExerciser(Thread):
self.core.log.info("API Excerciser started %d" % self.id)
- out = open("error.log", "ab")
- # core errors are not logged of course
- out.write("\n" + "Starting\n")
- out.flush()
-
- while True:
- try:
- self.testAPI()
- except Exception:
- self.core.log.error("Excerciser %d throw an execption" % self.id)
- print_exc()
- out.write(format_exc() + 2 * "\n")
- out.flush()
-
- if not self.count % 100:
- self.core.log.info("Exerciser %d tested %d api calls" % (self.id, self.count))
- if not self.count % 1000:
- out.flush()
-
- if not sumCalled % 1000: #: not thread safe
- self.core.log.info("Exercisers tested %d api calls" % sumCalled)
- persec = sumCalled / (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)
+ with open("error.log", "ab") as out:
+ # core errors are not logged of course
+ out.write("\n" + "Starting\n")
+ out.flush()
+
+ while True:
+ try:
+ self.testAPI()
+ except Exception:
+ self.core.log.error("Excerciser %d throw an execption" % self.id)
+ print_exc()
+ out.write(format_exc() + 2 * "\n")
+ out.flush()
+
+ if not self.count % 100:
+ self.core.log.info("Exerciser %d tested %d api calls" % (self.id, self.count))
+ if not self.count % 1000:
+ out.flush()
+
+ if not sumCalled % 1000: #: not thread safe
+ self.core.log.info("Exercisers tested %d api calls" % sumCalled)
+ persec = sumCalled / (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)
def testAPI(self):
diff --git a/tests/clonedigger.sh b/tests/clonedigger.sh
index 4c53eab0d..e7fd17eb6 100644
--- a/tests/clonedigger.sh
+++ b/tests/clonedigger.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-PYLOAD="../pyload" # Check pyload directory
+PYLOAD="../pyload" #: Check pyload directory
clonedigger -o cpd.xml --cpd-output --fast --ignore-dir="remote" ${PYLOAD}
diff --git a/tests/code_analysis.sh b/tests/code_analysis.sh
index cba614929..aaf6bb6a4 100644
--- a/tests/code_analysis.sh
+++ b/tests/code_analysis.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-PYLOAD="../pyload" # Check pyload directory
+PYLOAD="../pyload" #: Check pyload directory
echo "Running sloccount ..."
REPORT="sloccount.sc"
diff --git a/tests/test_api.py b/tests/test_api.py
index 13e783d54..1e02d8aa3 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -20,5 +20,5 @@ class TestApi(object):
@nottest
def test_random(self):
- for _i in range(0, 100):
+ for _i in xrange(0, 100):
self.api.testAPI()