[Libguestfs] [PATCH] python: tests: use more targeted assert*() functions/checks

Richard W.M. Jones rjones at redhat.com
Fri Feb 12 18:42:38 UTC 2016


On Fri, Feb 12, 2016 at 06:29:48PM +0100, Pino Toscano wrote:
> On Friday 12 February 2016 17:13:17 Richard W.M. Jones wrote:
> > On Fri, Feb 12, 2016 at 06:04:47PM +0100, Pino Toscano wrote:
> > > - use assertIsInstance, assertNotEqual, and assertIsNotNone as more
> > >   specific checks (will produce better logging)
> > > - use assertRaises when expecting exceptions being thrown
> > > - when testing internal_test_rhashtable, instead of checking type and
> > >   elements of the return values just check the return value as a whole
> > >   (easier and already getting all the work needed by unittest)
> > 
> > Good find!  I was going by the documentation which didn't mention any
> > of these asserts.
> 
> Hm I see all of them in
>   https://docs.python.org/2.7/library/unittest.html#test-cases

That's because I didn't read that far down the page :-(

> > ACK, assuming it also works with python3, ie this passes:
> > 
> >   PYTHON=/usr/bin/python3 ./configure && make && make -C test-data check && make -C python check
> 
> Usually I try on a Python3-only distribution (== Archlinux).  Since
> they passed there too, I pushed it.

Great, thanks.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list