From 00ee5b2289a81d7a0578dfb3aa8b69f6e9a2d3bd Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Fri, 18 Jul 2014 17:20:27 +0100 Subject: [PATCH] Unittest - Skip tests that use faketime if not available --- test/basetest/task.py | 7 +++++-- test/basetest/utils.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/basetest/task.py b/test/basetest/task.py index 61413241b..f6c263637 100644 --- a/test/basetest/task.py +++ b/test/basetest/task.py @@ -4,7 +4,8 @@ import os import tempfile import shutil import atexit -from .utils import run_cmd_wait, run_cmd_wait_nofail +import unittest +from .utils import run_cmd_wait, run_cmd_wait_nofail, which from .exceptions import CommandError @@ -242,7 +243,9 @@ class Task(object): If faketime is None, faketime settings will be disabled. """ - cmd = "faketime" + cmd = which("faketime") + if cmd is None: + raise unittest.SkipTest("libfaketime/faketime is not installed") if self._command[0] == cmd: self._command = self._command[3:] diff --git a/test/basetest/utils.py b/test/basetest/utils.py index bf68e60ec..f8d85b59e 100644 --- a/test/basetest/utils.py +++ b/test/basetest/utils.py @@ -4,6 +4,7 @@ import os import sys import socket import signal +import functools from subprocess import Popen, PIPE, STDOUT from threading import Thread from Queue import Queue, Empty