From f3330e144b1704e78c87b3dde8fd104ede84b7ba Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 18 Oct 2017 18:07:19 +0100 Subject: [PATCH] python: tests: Allow some tests to be skipped. Currently test820RHBZ912499.py fails with libvirt because libvirt still doesn't work around qemu locking properly. Allow this test to be skipped on a temporary basis using SKIP_TEST820RHBZ912499_PY=1 --- python/t/test820RHBZ912499.py | 1 + python/t/tests_helper.py.in | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/python/t/test820RHBZ912499.py b/python/t/test820RHBZ912499.py index 60509dc6a..f008f0c74 100644 --- a/python/t/test820RHBZ912499.py +++ b/python/t/test820RHBZ912499.py @@ -30,6 +30,7 @@ from .tests_helper import * # If the architecture doesn't support IDE, skip the test. +@skipIfEnvironmentVariableSet("SKIP_TEST820RHBZ912499_PY") @skipUnlessArchMatches("(i.86|x86_64)") @skipUnlessGuestfsBackendIs('libvirt') @skipUnlessLibvirtHasCPointer() diff --git a/python/t/tests_helper.py.in b/python/t/tests_helper.py.in index a024a4d62..91d1f8e85 100644 --- a/python/t/tests_helper.py.in +++ b/python/t/tests_helper.py.in @@ -18,6 +18,7 @@ # Utilities for the tests of the Python bindings. +import os import sys import unittest @@ -28,6 +29,16 @@ else: int_type = long +def skipIfEnvironmentVariableSet(name): + """ + Skip the current class/method if the named environment variable + is set to 1 + """ + if os.environ.get(name, "") == "1": + return unittest.skip("skipped by environment variable") + return lambda func: func + + def skipUnlessConfiguredWithLibvirt(): """ Skip the current class/method if ./configure --without-libvirt