Improve unitary test for client/server by using venv if possible

This commit is contained in:
nicolargo 2022-10-31 08:40:46 +01:00
parent 9758d18db1
commit 2b8ae361d1
2 changed files with 12 additions and 2 deletions

View File

@ -15,6 +15,7 @@ import subprocess
import time
import numbers
import unittest
import os
from glances import __version__
from glances.compat import text_type
@ -54,7 +55,11 @@ class TestGlances(unittest.TestCase):
global pid
print('INFO: [TEST_000] Start the Glances Web Server')
cmdline = "python -m glances -B localhost -w -p %s" % SERVER_PORT
if os.path.isfile("./venv/bin/python"):
cmdline = "./venv/bin/python"
else:
cmdline = "python"
cmdline += " -m glances -B localhost -w -p %s" % SERVER_PORT
print("Run the Glances Web Server on port %s" % SERVER_PORT)
args = shlex.split(cmdline)
pid = subprocess.Popen(args)

View File

@ -15,6 +15,7 @@ import shlex
import subprocess
import time
import unittest
import os
from glances import __version__
from glances.compat import ServerProxy
@ -43,7 +44,11 @@ class TestGlances(unittest.TestCase):
global pid
print('INFO: [TEST_000] Start the Glances Web Server')
cmdline = "python -m glances -B localhost -s -p %s" % SERVER_PORT
if os.path.isfile("./venv/bin/python"):
cmdline = "./venv/bin/python"
else:
cmdline = "python"
cmdline += " -m glances -B localhost -s --disable-autodiscover -p %s" % SERVER_PORT
print("Run the Glances Server on port %s" % SERVER_PORT)
args = shlex.split(cmdline)
pid = subprocess.Popen(args)