mirror of https://gitee.com/openkylin/qemu.git
iotests: use with-statement for open() calls
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>
This commit is contained in:
parent
b68ce82409
commit
06aad78b82
|
@ -1120,7 +1120,8 @@ def notrun(reason):
|
||||||
# Each test in qemu-iotests has a number ("seq")
|
# Each test in qemu-iotests has a number ("seq")
|
||||||
seq = os.path.basename(sys.argv[0])
|
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)
|
logger.warning("%s not run: %s", seq, reason)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -1133,8 +1134,8 @@ def case_notrun(reason):
|
||||||
# Each test in qemu-iotests has a number ("seq")
|
# Each test in qemu-iotests has a number ("seq")
|
||||||
seq = os.path.basename(sys.argv[0])
|
seq = os.path.basename(sys.argv[0])
|
||||||
|
|
||||||
open('%s/%s.casenotrun' % (output_dir, seq), 'a').write(
|
with open('%s/%s.casenotrun' % (output_dir, seq), 'a') as outfile:
|
||||||
' [case not run] ' + reason + '\n')
|
outfile.write(' [case not run] ' + reason + '\n')
|
||||||
|
|
||||||
def _verify_image_format(supported_fmts: Sequence[str] = (),
|
def _verify_image_format(supported_fmts: Sequence[str] = (),
|
||||||
unsupported_fmts: Sequence[str] = ()) -> None:
|
unsupported_fmts: Sequence[str] = ()) -> None:
|
||||||
|
|
Loading…
Reference in New Issue