Fix tests for Python 2.6

Our test cases use the `testtools` package which in turn relies on the
standard library `unittest` for the basic assert functions.

Unfortunately, Python 2.6's `unittest.TestCase` doesn't come with
`assertRegexpMatches` which we use in our tests. This caused the py26 Tox
environment to fail.

Adding `unittest2` (a backport of the 2.7 unittest for earlier versions) and
mixing it in with our base TestCase class adds the missing asserts.

Change-Id: Ifc69885421f167922b92a37f61dcab3db9665383
Signed-off-by: Tomas Sedovic <tsedovic@redhat.com>
This commit is contained in:
Tomas Sedovic 2013-08-22 17:53:36 +02:00
parent 0d833da823
commit c0a723455a
2 changed files with 5 additions and 1 deletions

View File

@ -16,3 +16,4 @@ python-subunit
sphinx>=1.1.2
testrepository>=0.0.13
testtools>=0.9.27
unittest2

View File

@ -34,6 +34,7 @@ import fixtures
import mox
import stubout
import testtools
import unittest2
from oslo.config import cfg
@ -145,7 +146,9 @@ class TestingException(Exception):
pass
class TestCase(testtools.TestCase):
# The unittest2.TestCase mixin provides assertRegexpMatches, which isn't
# available on Python 2.6 by default.
class TestCase(testtools.TestCase, unittest2.TestCase):
"""Test case base class for all unit tests."""
def setUp(self):