Merge "TestCase: add aliases to assert methods on py3"

This commit is contained in:
Jenkins 2015-09-28 11:18:20 +00:00 committed by Gerrit Code Review
commit a3254c02ad
2 changed files with 10 additions and 0 deletions

View File

@ -35,6 +35,7 @@ from django.test.client import RequestFactory # noqa
from django.test import testcases
from django.utils.encoding import force_text
from django.utils import unittest
import six
if django.VERSION < (1, 7):
from django.test import LiveServerTestCase # noqa
@ -169,6 +170,14 @@ class TestCase(django_test.TestCase):
if hasattr(self.user, "_perm_cache"):
del self.user._perm_cache
if six.PY3:
# Python 2 assert methods renamed in Python 3
def assertItemsEqual(self, expected_seq, actual_seq, msg=None):
self.assertCountEqual(expected_seq, actual_seq, msg)
def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
self.assertNotRegex(text, unexpected_regexp, msg)
def assertNoMessages(self, response=None):
"""Asserts that no messages have been attached by the
``contrib.messages`` framework.

View File

@ -24,6 +24,7 @@ commands =
python manage.py test --settings=horizon.test.settings \
horizon.test.tests.base \
horizon.test.tests.forms \
horizon.test.tests.messages \
horizon.test.tests.middleware \
horizon.test.tests.tables.DataTableViewTests \
horizon.test.tests.templatetags \