unitest-xmlrpc: unbreak non-Linux platforms

OK FreeBSD, OS X and Windows.
pull/686/head
Alessio Sergi 2015-09-21 19:09:09 +02:00
parent c513fe6fb5
commit 8ad7af6916
1 changed files with 4 additions and 16 deletions

View File

@ -32,12 +32,6 @@ except ImportError:
# Python 2
from xmlrpclib import ServerProxy
from glances.core.glances_globals import (
appname,
is_linux,
version
)
SERVER_PORT = 61234
URL = "http://localhost:%s" % SERVER_PORT
pid = None
@ -45,14 +39,6 @@ pid = None
# Global variables
# =================
# Unitary test is only available from a GNU/Linus machine
if not is_linux:
print(
'ERROR: XML/RPC API unitaries tests should be ran on GNU/Linux operating system')
sys.exit(2)
else:
print('Unitary tests for {0} {1}'.format(appname, version))
# Init Glances core
from glances.core.glances_main import GlancesMain
core = GlancesMain()
@ -64,12 +50,14 @@ if not core.is_standalone():
from glances.core.glances_stats import GlancesStats
stats = GlancesStats()
from glances.core.glances_globals import version
# Init the XML/RCP client
client = ServerProxy(URL)
# Unitest class
# ==============
print('XML-RPC API unitary tests for Glances %s' % version)
class TestGlances(unittest.TestCase):
@ -85,7 +73,7 @@ class TestGlances(unittest.TestCase):
global pid
cmdline = "/usr/bin/env python -m glances -s -p %s" % SERVER_PORT
cmdline = "python -m glances -s -p %s" % SERVER_PORT
print("Run the Glances Server on port %s" % SERVER_PORT)
args = shlex.split(cmdline)
pid = subprocess.Popen(args)