Loading django/utils/six.py +6 −0 Original line number Diff line number Diff line Loading @@ -393,9 +393,11 @@ def with_metaclass(meta, base=object): if PY3: _iterlists = "lists" _assertRaisesRegex = "assertRaisesRegex" _assertRegex = "assertRegex" else: _iterlists = "iterlists" _assertRaisesRegex = "assertRaisesRegexp" _assertRegex = "assertRegexpMatches" def iterlists(d): Loading @@ -407,5 +409,9 @@ def assertRaisesRegex(self, *args, **kwargs): return getattr(self, _assertRaisesRegex)(*args, **kwargs) def assertRegex(self, *args, **kwargs): return getattr(self, _assertRegex)(*args, **kwargs) add_move(MovedModule("_dummy_thread", "dummy_thread")) add_move(MovedModule("_thread", "thread")) docs/topics/python3.txt +7 −1 Original line number Diff line number Diff line Loading @@ -404,6 +404,12 @@ The version of six bundled with Django includes one extra function: ``testcase.assertRaisesRegex`` on Python 3. ``assertRaisesRegexp`` still exists in current Python 3 versions, but issues a warning. .. function:: assertRegex(testcase, *args, **kwargs) This replaces ``testcase.assertRegexpMatches`` on Python 2, and ``testcase.assertRegex`` on Python 3. ``assertRegexpMatches`` still exists in current Python 3 versions, but issues a warning. In addition to six' defaults moves, Django's version provides ``thread`` as ``_thread`` and ``dummy_thread`` as ``_dummy_thread``. tests/modeltests/timezones/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -506,7 +506,7 @@ class SerializationTests(TestCase): def assert_yaml_contains_datetime(self, yaml, dt): # Depending on the yaml dumper, '!timestamp' might be absent self.assertRegexpMatches(yaml, six.assertRegex(self, yaml, r"- fields: {dt: !(!timestamp)? '%s'}" % re.escape(dt)) def test_naive_datetime(self): Loading tests/regressiontests/admin_views/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -1263,7 +1263,7 @@ class AdminViewDeletedObjectsTest(TestCase): """ pattern = re.compile(br"""<li>Plot: <a href=".+/admin_views/plot/1/">World Domination</a>\s*<ul>\s*<li>Plot details: <a href=".+/admin_views/plotdetails/1/">almost finished</a>""") response = self.client.get('/test_admin/admin/admin_views/villain/%s/delete/' % quote(1)) self.assertRegexpMatches(response.content, pattern) six.assertRegex(self, response.content, pattern) def test_cyclic(self): """ Loading tests/regressiontests/i18n/commands/extraction.py +2 −1 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from django.core import management from django.test import SimpleTestCase from django.utils.encoding import force_text from django.utils._os import upath from django.utils import six from django.utils.six import StringIO Loading Loading @@ -112,7 +113,7 @@ class BasicExtractorTests(ExtractorTests): self.assertRaises(SyntaxError, management.call_command, 'makemessages', locale=LOCALE, extensions=['tpl'], verbosity=0) with self.assertRaises(SyntaxError) as context_manager: management.call_command('makemessages', locale=LOCALE, extensions=['tpl'], verbosity=0) self.assertRegexpMatches(str(context_manager.exception), six.assertRegex(self, str(context_manager.exception), r'Translation blocks must not include other block tags: blocktrans \(file templates[/\\]template_with_error\.tpl, line 3\)' ) # Check that the temporary file was cleaned up Loading Loading
django/utils/six.py +6 −0 Original line number Diff line number Diff line Loading @@ -393,9 +393,11 @@ def with_metaclass(meta, base=object): if PY3: _iterlists = "lists" _assertRaisesRegex = "assertRaisesRegex" _assertRegex = "assertRegex" else: _iterlists = "iterlists" _assertRaisesRegex = "assertRaisesRegexp" _assertRegex = "assertRegexpMatches" def iterlists(d): Loading @@ -407,5 +409,9 @@ def assertRaisesRegex(self, *args, **kwargs): return getattr(self, _assertRaisesRegex)(*args, **kwargs) def assertRegex(self, *args, **kwargs): return getattr(self, _assertRegex)(*args, **kwargs) add_move(MovedModule("_dummy_thread", "dummy_thread")) add_move(MovedModule("_thread", "thread"))
docs/topics/python3.txt +7 −1 Original line number Diff line number Diff line Loading @@ -404,6 +404,12 @@ The version of six bundled with Django includes one extra function: ``testcase.assertRaisesRegex`` on Python 3. ``assertRaisesRegexp`` still exists in current Python 3 versions, but issues a warning. .. function:: assertRegex(testcase, *args, **kwargs) This replaces ``testcase.assertRegexpMatches`` on Python 2, and ``testcase.assertRegex`` on Python 3. ``assertRegexpMatches`` still exists in current Python 3 versions, but issues a warning. In addition to six' defaults moves, Django's version provides ``thread`` as ``_thread`` and ``dummy_thread`` as ``_dummy_thread``.
tests/modeltests/timezones/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -506,7 +506,7 @@ class SerializationTests(TestCase): def assert_yaml_contains_datetime(self, yaml, dt): # Depending on the yaml dumper, '!timestamp' might be absent self.assertRegexpMatches(yaml, six.assertRegex(self, yaml, r"- fields: {dt: !(!timestamp)? '%s'}" % re.escape(dt)) def test_naive_datetime(self): Loading
tests/regressiontests/admin_views/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -1263,7 +1263,7 @@ class AdminViewDeletedObjectsTest(TestCase): """ pattern = re.compile(br"""<li>Plot: <a href=".+/admin_views/plot/1/">World Domination</a>\s*<ul>\s*<li>Plot details: <a href=".+/admin_views/plotdetails/1/">almost finished</a>""") response = self.client.get('/test_admin/admin/admin_views/villain/%s/delete/' % quote(1)) self.assertRegexpMatches(response.content, pattern) six.assertRegex(self, response.content, pattern) def test_cyclic(self): """ Loading
tests/regressiontests/i18n/commands/extraction.py +2 −1 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from django.core import management from django.test import SimpleTestCase from django.utils.encoding import force_text from django.utils._os import upath from django.utils import six from django.utils.six import StringIO Loading Loading @@ -112,7 +113,7 @@ class BasicExtractorTests(ExtractorTests): self.assertRaises(SyntaxError, management.call_command, 'makemessages', locale=LOCALE, extensions=['tpl'], verbosity=0) with self.assertRaises(SyntaxError) as context_manager: management.call_command('makemessages', locale=LOCALE, extensions=['tpl'], verbosity=0) self.assertRegexpMatches(str(context_manager.exception), six.assertRegex(self, str(context_manager.exception), r'Translation blocks must not include other block tags: blocktrans \(file templates[/\\]template_with_error\.tpl, line 3\)' ) # Check that the temporary file was cleaned up Loading