qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hanna Reitz <hreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Hanna Reitz <hreitz@redhat.com>,
	qemu-devel@nongnu.org
Subject: [PULL 19/56] iotests: use with-statement for open() calls
Date: Wed,  1 Sep 2021 17:15:42 +0200	[thread overview]
Message-ID: <20210901151619.689075-20-hreitz@redhat.com> (raw)
In-Reply-To: <20210901151619.689075-1-hreitz@redhat.com>

From: John Snow <jsnow@redhat.com>

Silences a new pylint warning. The dangers of *not* doing this are
somewhat unclear; I believe the file object gets garbage collected
eventually, but possibly the way in which it happens is
non-deterministic. Maybe this is a valid warning, but if there are
consequences of not doing it, I am not aware of them at present.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210720173336.1876937-2-jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 2cf5ff965b..2ad7a15c8b 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -1120,7 +1120,8 @@ def notrun(reason):
     # Each test in qemu-iotests has a number ("seq")
     seq = os.path.basename(sys.argv[0])
 
-    open('%s/%s.notrun' % (output_dir, seq), 'w').write(reason + '\n')
+    with open('%s/%s.notrun' % (output_dir, seq), 'w') as outfile:
+        outfile.write(reason + '\n')
     logger.warning("%s not run: %s", seq, reason)
     sys.exit(0)
 
@@ -1133,8 +1134,8 @@ def case_notrun(reason):
     # Each test in qemu-iotests has a number ("seq")
     seq = os.path.basename(sys.argv[0])
 
-    open('%s/%s.casenotrun' % (output_dir, seq), 'a').write(
-        '    [case not run] ' + reason + '\n')
+    with open('%s/%s.casenotrun' % (output_dir, seq), 'a') as outfile:
+        outfile.write('    [case not run] ' + reason + '\n')
 
 def _verify_image_format(supported_fmts: Sequence[str] = (),
                          unsupported_fmts: Sequence[str] = ()) -> None:
-- 
2.31.1



  parent reply	other threads:[~2021-09-01 15:36 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 15:15 [PULL 00/56] Block patches Hanna Reitz
2021-09-01 15:15 ` [PULL 01/56] python: qemu: add timer parameter for qmp.accept socket Hanna Reitz
2021-09-01 15:15 ` [PULL 02/56] python: Reduce strictness of pylint's duplicate-code check Hanna Reitz
2021-09-01 15:15 ` [PULL 03/56] python: qemu: pass the wrapper field from QEMUQtestmachine to QEMUMachine Hanna Reitz
2021-09-01 15:15 ` [PULL 04/56] docs/devel/testing: add debug section to the QEMU iotests chapter Hanna Reitz
2021-09-01 15:15 ` [PULL 05/56] qemu-iotests: add option to attach gdbserver Hanna Reitz
2021-09-01 15:15 ` [PULL 06/56] qemu-iotests: delay QMP socket timers Hanna Reitz
2021-09-01 15:15 ` [PULL 07/56] qemu_iotests: insert gdbserver command line as wrapper for qemu binary Hanna Reitz
2021-09-01 15:15 ` [PULL 08/56] qemu-iotests: add gdbserver option to script tests too Hanna Reitz
2021-09-01 15:15 ` [PULL 09/56] docs/devel/testing: add -gdb option to the debugging section of QEMU iotests Hanna Reitz
2021-09-01 15:15 ` [PULL 10/56] qemu-iotests: extend the check script to prepare supporting valgrind for python tests Hanna Reitz
2021-09-01 15:15 ` [PULL 11/56] qemu-iotests: extend QMP socket timeout when using valgrind Hanna Reitz
2021-09-01 15:15 ` [PULL 12/56] qemu-iotests: allow valgrind to read/delete the generated log file Hanna Reitz
2021-09-01 15:15 ` [PULL 13/56] qemu-iotests: insert valgrind command line as wrapper for qemu binary Hanna Reitz
2021-09-01 15:15 ` [PULL 14/56] docs/devel/testing: add -valgrind option to the debug section of QEMU iotests Hanna Reitz
2021-09-01 15:15 ` [PULL 15/56] qemu-iotests: add option to show qemu binary logs on stdout Hanna Reitz
2021-09-01 15:15 ` [PULL 16/56] docs/devel/testing: add -p option to the debug section of QEMU iotests Hanna Reitz
2021-09-01 15:15 ` [PULL 17/56] block/monitor: Consolidate hmp_handle_error calls to reduce redundant code Hanna Reitz
2021-09-01 15:15 ` [PULL 18/56] raw-format: drop WRITE and RESIZE child perms when possible Hanna Reitz
2021-09-01 15:15 ` Hanna Reitz [this message]
2021-09-01 15:15 ` [PULL 20/56] iotests: use subprocess.DEVNULL instead of open("/dev/null") Hanna Reitz
2021-09-01 15:15 ` [PULL 21/56] block: introduce bdrv_replace_child_bs() Hanna Reitz
2021-09-01 15:15 ` [PULL 22/56] block: introduce blk_replace_bs Hanna Reitz
2021-09-01 15:15 ` [PULL 23/56] qdev-properties: PropertyInfo: add realized_set_allowed field Hanna Reitz
2021-09-01 15:15 ` [PULL 24/56] qdev: allow setting drive property for realized device Hanna Reitz
2021-09-01 15:15 ` [PULL 25/56] block: rename backup-top to copy-before-write Hanna Reitz
2021-09-01 15:15 ` [PULL 26/56] block-copy: move detecting fleecing scheme to block-copy Hanna Reitz
2021-09-01 15:15 ` [PULL 27/56] block/block-copy: introduce block_copy_set_copy_opts() Hanna Reitz
2021-09-01 15:15 ` [PULL 28/56] block/backup: set copy_range and compress after filter insertion Hanna Reitz
2021-09-01 15:15 ` [PULL 29/56] block/backup: move cluster size calculation to block-copy Hanna Reitz
2021-09-01 15:15 ` [PULL 30/56] block/copy-before-write: relax permission requirements when no parents Hanna Reitz
2021-09-01 15:15 ` [PULL 31/56] block/copy-before-write: drop extra bdrv_unref on failure path Hanna Reitz
2021-09-01 15:15 ` [PULL 32/56] block/copy-before-write: use file child instead of backing Hanna Reitz
2021-09-01 15:15 ` [PULL 33/56] block/copy-before-write: bdrv_cbw_append(): replace child at last Hanna Reitz
2021-09-01 15:15 ` [PULL 34/56] block/copy-before-write: introduce cbw_init() Hanna Reitz
2021-09-01 15:15 ` [PULL 35/56] block/copy-before-write: cbw_init(): rename variables Hanna Reitz
2021-09-01 15:15 ` [PULL 36/56] block/copy-before-write: cbw_init(): use file child after attaching Hanna Reitz
2021-09-01 15:16 ` [PULL 37/56] block/copy-before-write: bdrv_cbw_append(): drop unused compress arg Hanna Reitz
2021-09-01 15:16 ` [PULL 38/56] block/copy-before-write: cbw_init(): use options Hanna Reitz
2021-09-01 15:16 ` [PULL 39/56] block/copy-before-write: initialize block-copy bitmap Hanna Reitz
2021-09-01 15:16 ` [PULL 40/56] block/block-copy: make setting progress optional Hanna Reitz
2021-09-01 15:16 ` [PULL 41/56] block/copy-before-write: make public block driver Hanna Reitz
2021-09-20  9:41   ` Kevin Wolf
2021-09-20 10:08     ` Vladimir Sementsov-Ogievskiy
2021-09-01 15:16 ` [PULL 42/56] qapi: publish copy-before-write filter Hanna Reitz
2021-09-01 15:16 ` [PULL 43/56] python/qemu/machine.py: refactor _qemu_args() Hanna Reitz
2021-09-01 15:16 ` [PULL 44/56] python/qemu/machine: QEMUMachine: improve qmp() method Hanna Reitz
2021-09-01 15:16 ` [PULL 45/56] python:QEMUMachine: template typing for self returning methods Hanna Reitz
2021-09-01 15:16 ` [PULL 46/56] iotests/222: fix pylint and mypy complains Hanna Reitz
2021-09-01 15:16 ` [PULL 47/56] iotests/222: constantly use single quotes for strings Hanna Reitz
2021-09-01 15:16 ` [PULL 48/56] iotests: move 222 to tests/image-fleecing Hanna Reitz
2021-09-01 15:16 ` [PULL 49/56] iotests.py: hmp_qemu_io: support qdev Hanna Reitz
2021-09-01 15:16 ` [PULL 50/56] iotests/image-fleecing: proper source device Hanna Reitz
2021-09-01 15:16 ` [PULL 51/56] iotests/image-fleecing: rename tgt_node Hanna Reitz
2021-09-01 15:16 ` [PULL 52/56] iotests/image-fleecing: prepare for adding new test-case Hanna Reitz
2021-09-01 15:16 ` [PULL 53/56] iotests/image-fleecing: add test-case for copy-before-write filter Hanna Reitz
2021-09-01 15:16 ` [PULL 54/56] block/block-copy: block_copy_state_new(): drop extra arguments Hanna Reitz
2021-09-01 15:16 ` [PULL 55/56] block/export/fuse.c: fix fuse-lseek on uclibc or musl Hanna Reitz
2021-09-01 15:16 ` [PULL 56/56] block/file-win32: add reopen handlers Hanna Reitz
2021-09-02 11:07 ` [PULL 00/56] Block patches Peter Maydell
2021-09-02 11:21   ` Hanna Reitz
2021-09-02 13:56 ` Peter Maydell

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=20210901151619.689075-20-hreitz@redhat.com \
    --to=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).