mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Applied ignore_warnings to Django tests
This commit is contained in:
parent
66f9a74b45
commit
51890ce889
57 changed files with 513 additions and 711 deletions
|
@ -1,7 +1,5 @@
|
|||
import warnings
|
||||
|
||||
from django.template import TemplateSyntaxError
|
||||
from django.test import SimpleTestCase
|
||||
from django.test import SimpleTestCase, ignore_warnings
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
|
||||
from ..utils import setup
|
||||
|
@ -129,48 +127,44 @@ class ForTagTests(SimpleTestCase):
|
|||
# These tests raise deprecation warnings and will raise an exception
|
||||
# in Django 2.0. The existing behavior is silent truncation if the
|
||||
# length of loopvars differs to the length of each set of items.
|
||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||
@setup({'for-tag-unpack10': '{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}'})
|
||||
def test_for_tag_unpack10(self):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", RemovedInDjango20Warning)
|
||||
output = self.engine.render_to_string(
|
||||
'for-tag-unpack10',
|
||||
{'items': (('one', 1, 'carrot'), ('two', 2, 'orange'))},
|
||||
)
|
||||
output = self.engine.render_to_string(
|
||||
'for-tag-unpack10',
|
||||
{'items': (('one', 1, 'carrot'), ('two', 2, 'orange'))},
|
||||
)
|
||||
self.assertEqual(output, 'one:1/two:2/')
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||
@setup({'for-tag-unpack11': '{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}'})
|
||||
def test_for_tag_unpack11(self):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", RemovedInDjango20Warning)
|
||||
output = self.engine.render_to_string(
|
||||
'for-tag-unpack11',
|
||||
{'items': (('one', 1), ('two', 2))},
|
||||
)
|
||||
output = self.engine.render_to_string(
|
||||
'for-tag-unpack11',
|
||||
{'items': (('one', 1), ('two', 2))},
|
||||
)
|
||||
|
||||
if self.engine.string_if_invalid:
|
||||
self.assertEqual(output, 'one:1,INVALID/two:2,INVALID/')
|
||||
else:
|
||||
self.assertEqual(output, 'one:1,/two:2,/')
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||
@setup({'for-tag-unpack12': '{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}'})
|
||||
def test_for_tag_unpack12(self):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", RemovedInDjango20Warning)
|
||||
output = self.engine.render_to_string(
|
||||
'for-tag-unpack12',
|
||||
{'items': (('one', 1, 'carrot'), ('two', 2))}
|
||||
)
|
||||
output = self.engine.render_to_string(
|
||||
'for-tag-unpack12',
|
||||
{'items': (('one', 1, 'carrot'), ('two', 2))}
|
||||
)
|
||||
if self.engine.string_if_invalid:
|
||||
self.assertEqual(output, 'one:1,carrot/two:2,INVALID/')
|
||||
else:
|
||||
self.assertEqual(output, 'one:1,carrot/two:2,/')
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||
@setup({'for-tag-unpack14': '{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}'})
|
||||
def test_for_tag_unpack14(self):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", RemovedInDjango20Warning)
|
||||
output = self.engine.render_to_string('for-tag-unpack14', {'items': (1, 2)})
|
||||
output = self.engine.render_to_string('for-tag-unpack14', {'items': (1, 2)})
|
||||
|
||||
if self.engine.string_if_invalid:
|
||||
self.assertEqual(output, 'INVALID:INVALID/INVALID:INVALID/')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue