qemu-iotests: use context managers for resource cleanup in 194
commit921a32179bb0a31c45a505f4ef36de4893be9612
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 24 Aug 2017 07:22:02 +0000 (24 08:22 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 5 Sep 2017 09:32:07 +0000 (5 10:32 +0100)
treeac63f9bb79c868024024253ef153eeb89697dd36
parentf4844ac0adabc458ba4610a71155448783d37c73
qemu-iotests: use context managers for resource cleanup in 194

Switch from atexit.register() to a more elegant idiom of declaring
resources in a with statement:

  with FilePath('monitor.sock') as monitor_path,
       VM() as vm:
      ...

The files and VMs will be automatically cleaned up whether the test
passes or fails.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20170824072202.26818-4-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
tests/qemu-iotests/194