On Tue, Mar 22, 2022 at 12:37 PM Hanna Reitz <hre...@redhat.com> wrote:
>
> On 18.03.22 21:36, John Snow wrote:
> > Modify this test to use assertRaises for its negative testing of
> > qemu_io. If the exception raised does not match the one we tell it to
> > expect, we get *that* exception unhandled. If we get no exception, we
> > get a unittest assertion failure and the provided emsg printed to
> > screen.
> >
> > If we get the CalledProcessError exception but the output is not what we
> > expect, we re-raise the original CalledProcessError.
> >
> > Tidy.
> >
> > Signed-off-by: John Snow <js...@redhat.com>
> > ---
> >   .../qemu-iotests/tests/migration-permissions  | 28 +++++++++----------
> >   1 file changed, 14 insertions(+), 14 deletions(-)
>
> Just like Eric I don’t find it so tidy that `ctx` exists outside of the
> `with` block, but re-raising the exception is indeed better, so:
>
> Reviewed-by: Hanna Reitz <hre...@redhat.com>
>

"Sorry about Python."

You still have the object, but __exit__() will have been called, so
resources will have been freed, references to live objects severed,
etc. unittests is designed around this for Exception testing, etc.
It's not a *real* scope. It just looks like one.

I'll add a little note in the commit message for the next person who wonders.

--js


Reply via email to