On Thu, Aug 24, 2017 at 08:21:59AM +0100, Stefan Hajnoczi wrote:
> 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
> 

Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next

Stefan

Reply via email to