summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--tox.ini23
-rwxr-xr-xunitest-restful.py2
-rwxr-xr-xunitest-xmlrpc.py8
4 files changed, 33 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index c80ac56e..27ff31f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,6 @@ local.properties
# Sphinx
_build
+
+# Tox
+.tox/
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 00000000..638e17f9
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,23 @@
+# Tox (http://tox.testrun.org/) is a tool for running tests
+# Install:
+# pip install tox
+# Run:
+# tox
+
+[tox]
+envlist = py27, py34
+
+[testenv]
+deps =
+ flake8
+ requests
+ psutil
+ bottle
+ batinfo
+ https://bitbucket.org/gleb_zhulik/py3sensors/get/tip.tar.gz
+commands =
+ python unitest.py
+ python unitest-restful.py
+ python unitest-xmlrpc.py
+ #flake8 --exclude=build,.tox,.git
+
diff --git a/unitest-restful.py b/unitest-restful.py
index 6f413c8f..061cb13e 100755
--- a/unitest-restful.py
+++ b/unitest-restful.py
@@ -123,7 +123,7 @@ class TestGlances(unittest.TestCase):
plist = requests.get("%s/%s" % (URL, method))
- print plist.json()
+ print(plist.json())
for p in plist.json():
print("HTTP RESTFul request: %s/%s" % (URL, p))
diff --git a/unitest-xmlrpc.py b/unitest-xmlrpc.py
index d1e56d4f..4d14ce13 100755
--- a/unitest-xmlrpc.py
+++ b/unitest-xmlrpc.py
@@ -27,9 +27,13 @@ import time
import unittest
import shlex
import subprocess
-import xmlrpclib
import json
import types
+try:
+ from xmlrpc.client import ServerProxy
+except ImportError:
+ # Python 2
+ from xmlrpclib import ServerProxy
from glances.core.glances_globals import (
appname,
@@ -68,7 +72,7 @@ from glances.core.glances_stats import GlancesStats
stats = GlancesStats()
# Init the XML/RCP client
-client = xmlrpclib.ServerProxy(URL)
+client = ServerProxy(URL)
# Unitest class
# ==============