qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	ehabkost@redhat.com, qemu-block@nongnu.org, armbru@redhat.com,
	Max Reitz <mreitz@redhat.com>, John Snow <jsnow@redhat.com>,
	philmd@redhat.com
Subject: [PATCH v10 04/14] iotests: replace mutable list default args
Date: Mon, 30 Mar 2020 20:00:04 -0400	[thread overview]
Message-ID: <20200331000014.11581-5-jsnow@redhat.com> (raw)
In-Reply-To: <20200331000014.11581-1-jsnow@redhat.com>

It's bad hygiene: if we modify this list, it will be modified across all
invocations.

(Remaining bad usages are fixed in a subsequent patch which changes the
function signature anyway.)

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 4d848339a5..51f84475d9 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -139,7 +139,7 @@ def qemu_img_log(*args):
     log(result, filters=[filter_testfiles])
     return result
 
-def img_info_log(filename, filter_path=None, imgopts=False, extra_args=[]):
+def img_info_log(filename, filter_path=None, imgopts=False, extra_args=()):
     args = ['info']
     if imgopts:
         args.append('--image-opts')
@@ -353,7 +353,7 @@ def _filter(_key, value):
         return value
     return filter_qmp(qmsg, _filter)
 
-def log(msg, filters=[], indent=None):
+def log(msg, filters=(), indent=None):
     '''Logs either a string message or a JSON serializable message (like QMP).
     If indent is provided, JSON serializable messages are pretty-printed.'''
     for flt in filters:
@@ -569,7 +569,7 @@ def get_qmp_events_filtered(self, wait=60.0):
             result.append(filter_qmp_event(ev))
         return result
 
-    def qmp_log(self, cmd, filters=[], indent=None, **kwargs):
+    def qmp_log(self, cmd, filters=(), indent=None, **kwargs):
         full_cmd = OrderedDict((
             ("execute", cmd),
             ("arguments", ordered_qmp(kwargs))
@@ -973,7 +973,7 @@ def case_notrun(reason):
     open('%s/%s.casenotrun' % (output_dir, seq), 'a').write(
         '    [case not run] ' + reason + '\n')
 
-def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
+def verify_image_format(supported_fmts=(), unsupported_fmts=()):
     assert not (supported_fmts and unsupported_fmts)
 
     if 'generic' in supported_fmts and \
@@ -987,7 +987,7 @@ def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
     if not_sup or (imgfmt in unsupported_fmts):
         notrun('not suitable for this image format: %s' % imgfmt)
 
-def verify_protocol(supported=[], unsupported=[]):
+def verify_protocol(supported=(), unsupported=()):
     assert not (supported and unsupported)
 
     if 'generic' in supported:
@@ -1006,11 +1006,11 @@ def verify_platform(supported=None, unsupported=None):
         if not any((sys.platform.startswith(x) for x in supported)):
             notrun('not suitable for this OS: %s' % sys.platform)
 
-def verify_cache_mode(supported_cache_modes=[]):
+def verify_cache_mode(supported_cache_modes=()):
     if supported_cache_modes and (cachemode not in supported_cache_modes):
         notrun('not suitable for this cache mode: %s' % cachemode)
 
-def verify_aio_mode(supported_aio_modes=[]):
+def verify_aio_mode(supported_aio_modes=()):
     if supported_aio_modes and (aiomode not in supported_aio_modes):
         notrun('not suitable for this aio mode: %s' % aiomode)
 
@@ -1050,7 +1050,7 @@ def supported_formats(read_only=False):
 
     return supported_formats.formats[read_only]
 
-def skip_if_unsupported(required_formats=[], read_only=False):
+def skip_if_unsupported(required_formats=(), read_only=False):
     '''Skip Test Decorator
        Runs the test if all the required formats are whitelisted'''
     def skip_test_decorator(func):
@@ -1101,11 +1101,11 @@ def execute_unittest(output, verbosity, debug):
             sys.stderr.write(out)
 
 def execute_test(test_function=None,
-                 supported_fmts=[],
+                 supported_fmts=(),
                  supported_platforms=None,
-                 supported_cache_modes=[], supported_aio_modes={},
-                 unsupported_fmts=[], supported_protocols=[],
-                 unsupported_protocols=[]):
+                 supported_cache_modes=(), supported_aio_modes=(),
+                 unsupported_fmts=(), supported_protocols=(),
+                 unsupported_protocols=()):
     """Run either unittest or script-style tests."""
 
     # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
-- 
2.21.1



  parent reply	other threads:[~2020-03-31  0:08 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31  0:00 [PATCH v10 00/14] iotests: use python logging John Snow
2020-03-31  0:00 ` [PATCH v10 01/14] iotests: do a light delinting John Snow
2020-03-31  0:00 ` [PATCH v10 02/14] iotests: don't use 'format' for drive_add John Snow
2020-03-31  0:00 ` [PATCH v10 03/14] iotests: ignore import warnings from pylint John Snow
2020-03-31  0:00 ` John Snow [this message]
2020-03-31  0:00 ` [PATCH v10 05/14] iotests: add pylintrc file John Snow
2020-03-31  0:00 ` [PATCH v10 06/14] iotests: alphabetize standard imports John Snow
2020-03-31  8:00   ` Philippe Mathieu-Daudé
2020-03-31  0:00 ` [PATCH v10 07/14] iotests: drop pre-Python 3.4 compatibility code John Snow
2020-03-31  0:00 ` [PATCH v10 08/14] iotests: touch up log function signature John Snow
2020-03-31  0:00 ` [PATCH v10 09/14] iotests: limit line length to 79 chars John Snow
2020-03-31  0:00 ` [PATCH v10 10/14] iotests: add hmp helper with logging John Snow
2020-03-31 10:21   ` Max Reitz
2020-03-31 14:00     ` Kevin Wolf
2020-04-01 12:28       ` Max Reitz
2020-04-01 12:42         ` Max Reitz
2020-04-01 13:51         ` Kevin Wolf
2020-04-01 14:53           ` Max Reitz
2020-03-31 17:23     ` John Snow
2020-03-31 17:39       ` Kevin Wolf
2020-04-01 12:40         ` Max Reitz
2020-04-02 18:27           ` John Snow
2020-04-03  7:46             ` Kevin Wolf
2020-04-03  8:57             ` Max Reitz
2020-04-04  2:38               ` John Snow
2020-03-31  0:00 ` [PATCH v10 11/14] iotests: add script_initialize John Snow
2020-03-31  0:00 ` [PATCH v10 12/14] iotest 258: use script_main John Snow
2020-03-31  0:00 ` [PATCH v10 13/14] iotests: Mark verify functions as private John Snow
2020-03-31 10:40   ` Max Reitz
2020-03-31  0:00 ` [PATCH v10 14/14] iotests: use python logging for iotests.log() John Snow
2020-03-31 13:44   ` Kevin Wolf
2020-05-14  6:24     ` John Snow
2020-05-14 10:06       ` Kevin Wolf
2020-05-14 19:54         ` John Snow
2020-05-15  9:03           ` Kevin Wolf
2020-05-18 18:29             ` John Snow
2020-03-31 15:07 ` [PATCH v10 00/14] iotests: use python logging Kevin Wolf
2020-04-28 11:46 ` Max Reitz
2020-04-28 12:21   ` Kevin Wolf
2020-04-28 17:36     ` John Snow
2020-04-29  8:08       ` Max Reitz

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=20200331000014.11581-5-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.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).