Remove backported unittest assertions in favour of unittest2.
Change-Id: I99535799838a68e3132414b32fef4a475d666ef3
This commit is contained in:
parent
d3fe6b8712
commit
16297b3394
@ -13,10 +13,8 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import sys
|
||||
import unittest
|
||||
import unittest2
|
||||
import mox
|
||||
from contextlib import contextmanager
|
||||
from moniker.openstack.common import cfg
|
||||
from moniker.openstack.common import log as logging
|
||||
from moniker.openstack.common.context import RequestContext, get_admin_context
|
||||
@ -26,7 +24,7 @@ from moniker.central import service as central_service
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestCase(unittest.TestCase):
|
||||
class TestCase(unittest2.TestCase):
|
||||
def setUp(self):
|
||||
super(TestCase, self).setUp()
|
||||
|
||||
@ -58,47 +56,3 @@ class TestCase(unittest.TestCase):
|
||||
|
||||
def get_admin_context(self):
|
||||
return get_admin_context()
|
||||
|
||||
if sys.version_info < (2, 7):
|
||||
# Add in some of the nicer methods not present in 2.6
|
||||
def assertIsNone(self, expr, msg=None):
|
||||
return self.assertEqual(expr, None, msg)
|
||||
|
||||
def assertIsNotNone(self, expr, msg=None):
|
||||
return self.assertNotEqual(expr, None, msg)
|
||||
|
||||
def assertIn(self, test_value, expected_set):
|
||||
msg = "%s did not occur in %s" % (test_value, expected_set)
|
||||
self.assert_(test_value in expected_set, msg)
|
||||
|
||||
def assertNotIn(self, test_value, expected_set):
|
||||
msg = "%s occurred in %s" % (test_value, expected_set)
|
||||
self.assert_(test_value not in expected_set, msg)
|
||||
|
||||
def assertGreaterEqual(self, a, b, msg=None):
|
||||
if not msg:
|
||||
msg = '%r not greater than or equal to %r' % (a, b)
|
||||
|
||||
self.assert_(a >= b, msg)
|
||||
|
||||
def assertLessEqual(self, a, b, msg=None):
|
||||
if not msg:
|
||||
msg = '%r not less than or equal to %r' % (a, b)
|
||||
|
||||
def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
|
||||
@contextmanager
|
||||
def context():
|
||||
raised = None
|
||||
try:
|
||||
yield
|
||||
except Exception, e:
|
||||
raised = e
|
||||
finally:
|
||||
if not isinstance(raised, excClass):
|
||||
raise self.failureException(
|
||||
"%s not raised" % str(excClass))
|
||||
|
||||
if callableObj is None:
|
||||
return context()
|
||||
with context:
|
||||
callableObj(*args, **kwargs)
|
||||
|
@ -7,3 +7,4 @@ coverage
|
||||
pep8==1.3.3
|
||||
sphinx
|
||||
sphinxcontrib-httpdomain
|
||||
unittest2
|
||||
|
Loading…
x
Reference in New Issue
Block a user