More pylint 2.8.x warning hushing: use open's context manager where it's applicable to do so to avoid a warning.
Signed-off-by: John Snow <js...@redhat.com> --- tests/qemu-iotests/iotests.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 46deb7f4dd4..5d5ec40429b 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -335,13 +335,12 @@ def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt): def create_image(name, size): '''Create a fully-allocated raw image with sector markers''' - file = open(name, 'wb') - i = 0 - while i < size: - sector = struct.pack('>l504xl', i // 512, i // 512) - file.write(sector) - i = i + 512 - file.close() + with open(name, 'wb') as outfile: + i = 0 + while i < size: + sector = struct.pack('>l504xl', i // 512, i // 512) + outfile.write(sector) + i = i + 512 def image_size(img): '''Return image's virtual size''' -- 2.30.2