From bc35f98723d8a957d9e08956664f0b052bffd3d8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 7 Sep 2015 15:20:36 +0200 Subject: [PATCH] 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 --- horizon/test/helpers.py | 9 +++++++++ tox.ini | 1 + 2 files changed, 10 insertions(+) diff --git a/horizon/test/helpers.py b/horizon/test/helpers.py index 5fcf58ee83..712c4899ff 100644 --- a/horizon/test/helpers.py +++ b/horizon/test/helpers.py @@ -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. diff --git a/tox.ini b/tox.ini index 1161049715..1c31f2e7bb 100644 --- a/tox.ini +++ b/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 \