• C
    selftests/unit/test_utils_process.py: skip test if sudo is not available · 33517beb
    Cleber Rosa 提交于
    test_run_sudo() actually needs sudo, because it attempts to run it.
    Let's check for the file at the usual location, and skip the test
    unless it exists.
    
       ERROR: test_run_sudo (selftests.unit.test_utils_process.TestProcessRun)
       ----------------------------------------------------------------------
       Traceback (most recent call last):
         File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
           return func(*args, **keywargs)
         File "selftests/unit/test_utils_process.py", line 180, in test_run_sudo
           p = process.run(cmd='ls -l', sudo=True, ignore_status=True)
         File "avocado/utils/process.py", line 1272, in run
           cmd_result = sp.run(timeout=timeout)
         File "avocado/utils/process.py", line 781, in run
           self._init_subprocess()
         File "avocado/utils/process.py", line 571, in _init_subprocess
           raise details
       OSError: [Errno 2] No such file or directory (/bin/sudo -n ls -l)
    Signed-off-by: NCleber Rosa <crosa@redhat.com>
    33517beb
test_utils_process.py 15.9 KB