[openstack-dev] Testtools usage?

Monty Taylor mordred at inaugust.com
Thu Jan 24 21:39:02 UTC 2013

On 01/25/2013 08:17 AM, Joshua Harlow wrote:
> Hi all,
> Just was investigating some odd test failures,
> http://logs.openstack.org/20425/1/check/gate-python-keystoneclient-python26/605/console.html
> Looking at some of the other components code (keystone) it uses
> unittest2 to take the py2.7 backport and import it as 'unittest' (a
> confusing rename).
> https://github.com/openstack/keystone/blob/master/keystone/test.py#L27
> It seems like there is a move to testtools, but testtools.TestCase
> doesn't seem to derive from unittest2 (it uses unittest.TestCase) so
> this means that functions that previously existed before the switch to
> testtools won't exist in python 2.6, have other openstack sub-projects
> that have been moving to testtools fixed this, or perhaps there should
> be a upstream fix for testtools to attempt to derive its testcase class
> from unittest2?

Yup. Keystone was actually next on my list to port to testtools. :)

> Wondering how others py2.6 support hasn't been busted.

In porting nova, I made use of the testtools matchers functionality and
self.assertThat. testtools.matchers.MatchesDict is, I believe, equiv to
unittest2's assertDictEqual. Additionally, in nova we made a DictEqual
matcher (crappy name, sorry) which does a deep match. We should probably
port that up into testtools itself.


More information about the OpenStack-dev mailing list