summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2019-02-09 19:18:48 +0500
committerTim Graham <timograham@gmail.com>2019-02-09 09:18:48 -0500
commit1933e56eca1ad17de7dd133bfb7cbee9858a75a3 (patch)
tree3dbc7a8fa58cba631591ebdfa22c687948fbb887 /tests
parentb1a2ad69251053a5f1ce71ffa95b188c4a765388 (diff)
Removed uneeded generator expressions and list comprehensions.
Diffstat (limited to 'tests')
-rw-r--r--tests/invalid_models_tests/test_ordinary_fields.py4
-rw-r--r--tests/lookup/tests.py2
-rw-r--r--tests/mail/tests.py4
-rw-r--r--tests/queries/tests.py4
-rw-r--r--tests/template_tests/test_response.py10
5 files changed, 12 insertions, 12 deletions
diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py
index 9c7cf7f88c..a106ab175a 100644
--- a/tests/invalid_models_tests/test_ordinary_fields.py
+++ b/tests/invalid_models_tests/test_ordinary_fields.py
@@ -156,14 +156,14 @@ class CharFieldTests(SimpleTestCase):
self.display = display
def __iter__(self):
- return (x for x in [self.value, self.display])
+ return iter((self.value, self.display))
def __len__(self):
return 2
class Things:
def __iter__(self):
- return (x for x in [ThingItem(1, 2), ThingItem(3, 4)])
+ return iter((ThingItem(1, 2), ThingItem(3, 4)))
class ThingWithIterableChoices(models.Model):
thing = models.CharField(max_length=100, blank=True, choices=Things())
diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py
index 3d68c04ea0..666fadf262 100644
--- a/tests/lookup/tests.py
+++ b/tests/lookup/tests.py
@@ -531,7 +531,7 @@ class LookupTests(TestCase):
self.assertQuerysetEqual(Article.objects.filter(headline__startswith='Article').none(), [])
self.assertEqual(Article.objects.none().count(), 0)
self.assertEqual(Article.objects.none().update(headline="This should not take effect"), 0)
- self.assertQuerysetEqual([article for article in Article.objects.none().iterator()], [])
+ self.assertQuerysetEqual(Article.objects.none().iterator(), [])
def test_in(self):
# using __in with an empty list should return an empty query set
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 029d332c42..9d8d21c3e7 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -844,8 +844,8 @@ class BaseEmailBackendTests(HeadersCheckMixin):
def test_send_many(self):
email1 = EmailMessage('Subject', 'Content1', 'from@example.com', ['to@example.com'])
email2 = EmailMessage('Subject', 'Content2', 'from@example.com', ['to@example.com'])
- # send_messages() may take a list or a generator.
- emails_lists = ([email1, email2], (email for email in [email1, email2]))
+ # send_messages() may take a list or an iterator.
+ emails_lists = ([email1, email2], iter((email1, email2)))
for emails_list in emails_lists:
num_sent = mail.get_connection().send_messages(emails_list)
self.assertEqual(num_sent, 2)
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 60e4243315..8128deca8b 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -1935,9 +1935,9 @@ class RawQueriesTests(TestCase):
class GeneratorExpressionTests(SimpleTestCase):
def test_ticket10432(self):
- # Using an empty generator expression as the rvalue for an "__in"
+ # Using an empty iterator as the rvalue for an "__in"
# lookup is legal.
- self.assertCountEqual(Note.objects.filter(pk__in=(x for x in ())), [])
+ self.assertCountEqual(Note.objects.filter(pk__in=iter(())), [])
class ComparisonTests(TestCase):
diff --git a/tests/template_tests/test_response.py b/tests/template_tests/test_response.py
index b0d66dc809..9fcc0a9c7c 100644
--- a/tests/template_tests/test_response.py
+++ b/tests/template_tests/test_response.py
@@ -77,17 +77,17 @@ class SimpleTemplateResponseTest(SimpleTestCase):
self.assertFalse(response.is_rendered)
def iteration():
- for x in response:
- pass
- with self.assertRaises(ContentNotRenderedError):
+ list(response)
+
+ msg = 'The response content must be rendered before it can be iterated over.'
+ with self.assertRaisesMessage(ContentNotRenderedError, msg):
iteration()
self.assertFalse(response.is_rendered)
def test_iteration_rendered(self):
# iteration works for rendered responses
response = self._response().render()
- res = [x for x in response]
- self.assertEqual(res, [b'foo'])
+ self.assertEqual(list(response), [b'foo'])
def test_content_access_unrendered(self):
# unrendered response raises an exception when content is accessed