TestCase: add aliases to assert methods on py3
The Python 2 assertItemsEqual() method was renamed to assertCountEqual() in Python 3, and assertNotRegexpMatches() was renamed to assertNotRegex(). Add aliases in horizon.test.helpers.TestCase. tox.ini: add horizon.test.tests.messages to Python 3.4. Partial-Implements: blueprint porting-python3 Change-Id: If7abd51fd3559a5ab32d433c6dc3476bd678b2bf
This commit is contained in:
parent
bd71ffe34b
commit
bc35f98723
@ -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.
|
||||
|
1
tox.ini
1
tox.ini
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user