[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 0/3] iotests: clean up resources using context manag
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers |
Date: |
Thu, 24 Aug 2017 08:21:59 +0100 |
This series introduces context managers for the two most commonly used
resources: files and VMs. Context managers eliminate the need to call a
cleanup function explicitly.
Tests should declare resources upfront in a with statement. Resources are
automatically cleaned up whether the test passes or fails:
with FilePath('test.img') as img_path,
VM() as vm:
...test...
# img_path is deleted and vm is shut down automatically
The final patch converts 194 to use context managers instead of
atexit.register(). This makes the code shorter and easier to read.
Stefan Hajnoczi (3):
qemu.py: make VM() a context manager
iotests.py: add FilePath context manager
qemu-iotests: use context managers for resource cleanup in 194
scripts/qemu.py | 16 ++++++++-
tests/qemu-iotests/194 | 83 +++++++++++++++++++++----------------------
tests/qemu-iotests/iotests.py | 26 ++++++++++++++
3 files changed, 82 insertions(+), 43 deletions(-)
--
2.13.5
- [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers,
Stefan Hajnoczi <=