mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-19 05:58:34 +02:00
Display test results on stdout.
This commit is contained in:
+10
-5
@@ -9,7 +9,7 @@ import inspect
|
||||
import re
|
||||
|
||||
|
||||
def exec_cmd(cmd, sudo_user=None, **kwargs):
|
||||
def exec_cmd(cmd, sudo_user=None, capture_output=True, **kwargs):
|
||||
"""Execute a shell command.
|
||||
|
||||
Run a command using the current user. Set :keyword:`sudo_user` if
|
||||
@@ -22,10 +22,15 @@ def exec_cmd(cmd, sudo_user=None, **kwargs):
|
||||
"""
|
||||
if sudo_user is not None:
|
||||
cmd = "sudo -u %s %s" % (sudo_user, cmd)
|
||||
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT, **kwargs)
|
||||
output = p.communicate()[0]
|
||||
return p.returncode, output
|
||||
kwargs["shell"] = True
|
||||
if capture_output:
|
||||
kwargs.update(stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
p = subprocess.Popen(cmd, **kwargs)
|
||||
output = p.communicate()[0]
|
||||
return p.returncode, output
|
||||
p = subprocess.Popen(cmd, **kwargs)
|
||||
p.wait()
|
||||
return p.returncode, None
|
||||
|
||||
|
||||
def guess_extension_name():
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import os
|
||||
import tempfile
|
||||
import pexpect
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from modoboa.lib.sysutils import exec_cmd
|
||||
|
||||
|
||||
@@ -20,7 +20,11 @@ class DeployTest(unittest.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
path = os.path.join(self.workdir, self.projname)
|
||||
code, output = exec_cmd("python manage.py test core lib admin limits postfix_relay_domains", cwd=path)
|
||||
code, output = exec_cmd(
|
||||
"python manage.py test core lib admin limits postfix_relay_domains",
|
||||
capture_output=False,
|
||||
cwd=path
|
||||
)
|
||||
self.assertEqual(code, 0)
|
||||
|
||||
def test_standard(self):
|
||||
|
||||
Reference in New Issue
Block a user