Skip to content

Commit 00f119f

Browse files
philmdrth7680
authored andcommitted
tests/functional: Add a decorator for skipping tests on particular OS
Since tests might be failing on some operating systems, introduce the skipIfOperatingSystem() decorator. Acked-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-ID: <[email protected]>
1 parent 4412d71 commit 00f119f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

tests/functional/qemu_test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
from .linuxkernel import LinuxKernelTest
1616
from .decorators import skipIfMissingCommands, skipIfNotMachine, \
1717
skipFlakyTest, skipUntrustedTest, skipBigDataTest, skipSlowTest, \
18-
skipIfMissingImports
18+
skipIfMissingImports, skipIfOperatingSystem
1919
from .archive import archive_extract
2020
from .uncompress import uncompress

tests/functional/qemu_test/decorators.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import importlib
66
import os
77
import platform
8-
from unittest import skipUnless
8+
from unittest import skipIf, skipUnless
99

1010
from .cmd import which
1111

@@ -26,6 +26,19 @@ def skipIfMissingCommands(*args):
2626
return skipUnless(has_cmds, 'required command(s) "%s" not installed' %
2727
", ".join(args))
2828

29+
'''
30+
Decorator to skip execution of a test if the current
31+
host operating system does match one of the prohibited
32+
ones.
33+
Example
34+
35+
@skipIfOperatingSystem("Linux", "Darwin")
36+
'''
37+
def skipIfOperatingSystem(*args):
38+
return skipIf(platform.system() in args,
39+
'running on an OS (%s) that is not able to run this test' %
40+
", ".join(args))
41+
2942
'''
3043
Decorator to skip execution of a test if the current
3144
host machine does not match one of the permitted

0 commit comments

Comments
 (0)