From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 2/6] tests/functional: Fix problems in decorators.py reported by pylint
Date: Wed, 15 Oct 2025 11:54:50 +0200 [thread overview]
Message-ID: <20251015095454.1575318-3-thuth@redhat.com> (raw)
In-Reply-To: <20251015095454.1575318-1-thuth@redhat.com>
From: Thomas Huth <thuth@redhat.com>
The documentation strings should follow the function definition
lines, not precede them.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/qemu_test/decorators.py | 176 +++++++++++------------
1 file changed, 87 insertions(+), 89 deletions(-)
diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qemu_test/decorators.py
index b2392958041..807418359ab 100644
--- a/tests/functional/qemu_test/decorators.py
+++ b/tests/functional/qemu_test/decorators.py
@@ -10,136 +10,134 @@
from .cmd import which
-'''
-Decorator to skip execution of a test if the provided
-environment variables are not set.
-Example:
- @skipIfMissingEnv("QEMU_ENV_VAR0", "QEMU_ENV_VAR1")
-'''
def skipIfMissingEnv(*vars_):
+ '''
+ Decorator to skip execution of a test if the provided
+ environment variables are not set.
+ Example:
+
+ @skipIfMissingEnv("QEMU_ENV_VAR0", "QEMU_ENV_VAR1")
+ '''
missing_vars = []
for var in vars_:
- if os.getenv(var) == None:
+ if os.getenv(var) is None:
missing_vars.append(var)
- has_vars = True if len(missing_vars) == 0 else False
+ has_vars = len(missing_vars) == 0
return skipUnless(has_vars, f"Missing env var(s): {', '.join(missing_vars)}")
-'''
-
-Decorator to skip execution of a test if the list
-of command binaries is not available in $PATH.
-Example:
-
- @skipIfMissingCommands("mkisofs", "losetup")
-'''
def skipIfMissingCommands(*args):
+ '''
+ Decorator to skip execution of a test if the list
+ of command binaries is not available in $PATH.
+ Example:
+
+ @skipIfMissingCommands("mkisofs", "losetup")
+ '''
has_cmds = True
for cmd in args:
- if not which(cmd):
- has_cmds = False
- break
+ if not which(cmd):
+ has_cmds = False
+ break
return skipUnless(has_cmds, 'required command(s) "%s" not installed' %
", ".join(args))
-'''
-Decorator to skip execution of a test if the current
-host operating system does match one of the prohibited
-ones.
-Example
-
- @skipIfOperatingSystem("Linux", "Darwin")
-'''
def skipIfOperatingSystem(*args):
+ '''
+ Decorator to skip execution of a test if the current host
+ operating system does match one of the prohibited ones.
+ Example:
+
+ @skipIfOperatingSystem("Linux", "Darwin")
+ '''
return skipIf(platform.system() in args,
'running on an OS (%s) that is not able to run this test' %
", ".join(args))
-'''
-Decorator to skip execution of a test if the current
-host machine does not match one of the permitted
-machines.
-Example
-
- @skipIfNotMachine("x86_64", "aarch64")
-'''
def skipIfNotMachine(*args):
+ '''
+ Decorator to skip execution of a test if the current
+ host machine does not match one of the permitted machines.
+ Example:
+
+ @skipIfNotMachine("x86_64", "aarch64")
+ '''
return skipUnless(platform.machine() in args,
'not running on one of the required machine(s) "%s"' %
", ".join(args))
-'''
-Decorator to skip execution of flaky tests, unless
-the $QEMU_TEST_FLAKY_TESTS environment variable is set.
-A bug URL must be provided that documents the observed
-failure behaviour, so it can be tracked & re-evaluated
-in future.
+def skipFlakyTest(bug_url):
+ '''
+ Decorator to skip execution of flaky tests, unless
+ the $QEMU_TEST_FLAKY_TESTS environment variable is set.
+ A bug URL must be provided that documents the observed
+ failure behaviour, so it can be tracked & re-evaluated
+ in future.
-Historical tests may be providing "None" as the bug_url
-but this should not be done for new test.
+ Historical tests may be providing "None" as the bug_url
+ but this should not be done for new test.
-Example:
+ Example:
- @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/NNN")
-'''
-def skipFlakyTest(bug_url):
+ @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/NNN")
+ '''
if bug_url is None:
bug_url = "FIXME: reproduce flaky test and file bug report or remove"
return skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'),
f'Test is unstable: {bug_url}')
-'''
-Decorator to skip execution of tests which are likely
-to execute untrusted commands on the host, or commands
-which process untrusted code, unless the
-$QEMU_TEST_ALLOW_UNTRUSTED_CODE env var is set.
-Example:
-
- @skipUntrustedTest()
-'''
def skipUntrustedTest():
+ '''
+ Decorator to skip execution of tests which are likely
+ to execute untrusted commands on the host, or commands
+ which process untrusted code, unless the
+ $QEMU_TEST_ALLOW_UNTRUSTED_CODE env var is set.
+ Example:
+
+ @skipUntrustedTest()
+ '''
return skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'),
'Test runs untrusted code / processes untrusted data')
-'''
-Decorator to skip execution of tests which need large
-data storage (over around 500MB-1GB mark) on the host,
-unless the $QEMU_TEST_ALLOW_LARGE_STORAGE environment
-variable is set
+def skipBigDataTest():
+ '''
+ Decorator to skip execution of tests which need large
+ data storage (over around 500MB-1GB mark) on the host,
+ unless the $QEMU_TEST_ALLOW_LARGE_STORAGE environment
+ variable is set
-Example:
+ Example:
- @skipBigDataTest()
-'''
-def skipBigDataTest():
+ @skipBigDataTest()
+ '''
return skipUnless(os.getenv('QEMU_TEST_ALLOW_LARGE_STORAGE'),
'Test requires large host storage space')
-'''
-Decorator to skip execution of tests which have a really long
-runtime (and might e.g. time out if QEMU has been compiled with
-debugging enabled) unless the $QEMU_TEST_ALLOW_SLOW
-environment variable is set
+def skipSlowTest():
+ '''
+ Decorator to skip execution of tests which have a really long
+ runtime (and might e.g. time out if QEMU has been compiled with
+ debugging enabled) unless the $QEMU_TEST_ALLOW_SLOW
+ environment variable is set
-Example:
+ Example:
- @skipSlowTest()
-'''
-def skipSlowTest():
+ @skipSlowTest()
+ '''
return skipUnless(os.getenv('QEMU_TEST_ALLOW_SLOW'),
'Test has a very long runtime and might time out')
-'''
-Decorator to skip execution of a test if the list
-of python imports is not available.
-Example:
-
- @skipIfMissingImports("numpy", "cv2")
-'''
def skipIfMissingImports(*args):
+ '''
+ Decorator to skip execution of a test if the list
+ of python imports is not available.
+ Example:
+
+ @skipIfMissingImports("numpy", "cv2")
+ '''
has_imports = True
for impname in args:
try:
@@ -151,15 +149,15 @@ def skipIfMissingImports(*args):
return skipUnless(has_imports, 'required import(s) "%s" not installed' %
", ".join(args))
-'''
-Decorator to skip execution of a test if the system's
-locked memory limit is below the required threshold.
-Takes required locked memory threshold in kB.
-Example:
-
- @skipLockedMemoryTest(2_097_152)
-'''
def skipLockedMemoryTest(locked_memory):
+ '''
+ Decorator to skip execution of a test if the system's
+ locked memory limit is below the required threshold.
+ Takes required locked memory threshold in kB.
+ Example:
+
+ @skipLockedMemoryTest(2_097_152)
+ '''
# get memlock hard limit in bytes
_, ulimit_memory = resource.getrlimit(resource.RLIMIT_MEMLOCK)
--
2.51.0
next prev parent reply other threads:[~2025-10-15 9:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 9:54 [PATCH 0/6] tests/functional: Fix various problems reported by pylint Thomas Huth
2025-10-15 9:54 ` [PATCH 1/6] tests/functional: Fix problems in asset.py " Thomas Huth
2025-10-15 9:54 ` Thomas Huth [this message]
2025-10-22 19:15 ` [PATCH 2/6] tests/functional: Fix problems in decorators.py " Philippe Mathieu-Daudé
2025-10-15 9:54 ` [PATCH 3/6] tests/functional: Fix problems in linuxkerenl.py " Thomas Huth
2025-10-22 19:14 ` Philippe Mathieu-Daudé
2025-10-23 6:46 ` Thomas Huth
2025-10-23 15:13 ` John Snow
2025-10-15 9:54 ` [PATCH 4/6] tests/functional: Fix problems in testcase.py " Thomas Huth
2025-10-22 19:10 ` Philippe Mathieu-Daudé
2025-10-23 4:57 ` Thomas Huth
2025-10-15 9:54 ` [PATCH 5/6] tests/functional: Fix problems in uncompress.py " Thomas Huth
2025-10-22 19:07 ` Philippe Mathieu-Daudé
2025-10-15 9:54 ` [PATCH 6/6] tests/functional: Fix problems in utils.py " Thomas Huth
2025-10-22 19:07 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251015095454.1575318-3-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=berrange@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).