From 15173dd431f588c43eb22226920acaf337d2fbc6 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Wed, 25 Aug 2021 13:07:44 +0200 Subject: [PATCH] Correct unitests --- glances/compat.py | 2 +- unitest-restful.py | 9 +++++++-- unitest-xmlrpc.py | 7 ++++++- unitest.py | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/glances/compat.py b/glances/compat.py index 4c788482..58952fc2 100644 --- a/glances/compat.py +++ b/glances/compat.py @@ -2,7 +2,7 @@ # # This file is part of Glances. # -# Copyright (C) 2019 Nicolargo +# Copyright (C) 2021 Nicolargo # # Glances is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by diff --git a/unitest-restful.py b/unitest-restful.py index 7b77a2b9..8e9b8655 100755 --- a/unitest-restful.py +++ b/unitest-restful.py @@ -3,7 +3,7 @@ # # Glances - An eye on your system # -# Copyright (C) 2019 Nicolargo +# Copyright (C) 2021 Nicolargo # # Glances is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by @@ -20,6 +20,7 @@ """Glances unitary tests suite for the RESTful API.""" +import os import shlex import subprocess import time @@ -64,7 +65,11 @@ class TestGlances(unittest.TestCase): global pid print('INFO: [TEST_000] Start the Glances Web Server') - cmdline = "python -m glances -w -p %s" % SERVER_PORT + if os.path.isfile('./venv/bin/python'): + cmdline = "./venv/bin/python" + else: + cmdline = "python" + cmdline += " -m glances -w -p %s" % SERVER_PORT print("Run the Glances Web Server on port %s" % SERVER_PORT) args = shlex.split(cmdline) pid = subprocess.Popen(args) diff --git a/unitest-xmlrpc.py b/unitest-xmlrpc.py index 7e52ec5e..69918047 100755 --- a/unitest-xmlrpc.py +++ b/unitest-xmlrpc.py @@ -20,6 +20,7 @@ """Glances unitary tests suite for the XML-RPC API.""" +import os import json import shlex import subprocess @@ -53,7 +54,11 @@ class TestGlances(unittest.TestCase): global pid print('INFO: [TEST_000] Start the Glances Web Server') - cmdline = "python -m glances -s -p %s" % SERVER_PORT + if os.path.isfile('./venv/bin/python'): + cmdline = "./venv/bin/python" + else: + cmdline = "python" + cmdline += " -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) diff --git a/unitest.py b/unitest.py index 750c0111..2543dc73 100755 --- a/unitest.py +++ b/unitest.py @@ -3,7 +3,7 @@ # # Glances - An eye on your system # -# Copyright (C) 2019 Nicolargo +# Copyright (C) 2021 Nicolargo # # Glances is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by