summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-10-10 11:07:48 -0400
committerTim Graham <timograham@gmail.com>2013-10-10 11:09:42 -0400
commitadedc310729f7b1ca182b7b38d7d47550ae3e89d (patch)
tree89ae4ff6019d24d7ffb1e14ea3ae860c8522d31f /tests
parentcec11a3336c730e6dc2f1966fee749cc830e97c0 (diff)
downloaddjango-adedc310729f7b1ca182b7b38d7d47550ae3e89d.tar.gz
Fixed "redefinition of unused 'foo' from line X" pyflakes warnings.
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_views/admin.py5
-rw-r--r--tests/base/models.py2
-rw-r--r--tests/forms_tests/tests/test_media.py2
-rw-r--r--tests/m2m_and_m2o/tests.py3
-rw-r--r--tests/mail/tests.py24
-rw-r--r--tests/multiple_database/tests.py12
6 files changed, 22 insertions, 26 deletions
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
index 5ecc085a78..85f6298a18 100644
--- a/tests/admin_views/admin.py
+++ b/tests/admin_views/admin.py
@@ -567,11 +567,6 @@ class AlbumAdmin(admin.ModelAdmin):
list_filter = ['title']
-class WorkHourAdmin(admin.ModelAdmin):
- list_display = ('datum', 'employee')
- list_filter = ('employee',)
-
-
class PrePopulatedPostLargeSlugAdmin(admin.ModelAdmin):
prepopulated_fields = {
'slug' : ('title',)
diff --git a/tests/base/models.py b/tests/base/models.py
index 98d379337c..23efdf9d5b 100644
--- a/tests/base/models.py
+++ b/tests/base/models.py
@@ -20,6 +20,6 @@ class MyModel(six.with_metaclass(CustomBaseModel, models.Model)):
# still does not fail to create the model.
if six.PY2:
- class MyModel(models.Model):
+ class MyPython2Model(models.Model):
"""Model subclass with a custom base using __metaclass__."""
__metaclass__ = CustomBaseModel
diff --git a/tests/forms_tests/tests/test_media.py b/tests/forms_tests/tests/test_media.py
index c492a1e539..7061759bc3 100644
--- a/tests/forms_tests/tests/test_media.py
+++ b/tests/forms_tests/tests/test_media.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-from django.forms import TextInput, Media, TextInput, CharField, Form, MultiWidget
+from django.forms import Media, TextInput, CharField, Form, MultiWidget
from django.template import Template, Context
from django.test import TestCase
from django.test.utils import override_settings
diff --git a/tests/m2m_and_m2o/tests.py b/tests/m2m_and_m2o/tests.py
index 0380ad4b08..646212bf4f 100644
--- a/tests/m2m_and_m2o/tests.py
+++ b/tests/m2m_and_m2o/tests.py
@@ -74,7 +74,7 @@ class RelatedObjectTests(TestCase):
lambda i: i.num
)
-class RelatedObjectTests(TestCase):
+class RelatedObjectUnicodeTests(TestCase):
def test_m2m_with_unicode_reference(self):
"""
Regression test for #6045: references to other models can be unicode
@@ -85,4 +85,3 @@ class RelatedObjectTests(TestCase):
m2.others.add(m1) # used to cause an error (see ticket #6045)
m2.save()
list(m2.others.all()) # Force retrieval.
-
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 7bef1a3bb3..ec99afb5a7 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
import asyncore
-import email
+from email import message_from_file, message_from_string
from email.mime.text import MIMEText
import os
import shutil
@@ -24,6 +24,11 @@ from django.utils.encoding import force_str, force_text
from django.utils.six import PY3, StringIO, string_types
from django.utils.translation import ugettext_lazy
+if PY3:
+ from email.utils import parseaddr
+else:
+ from email.Utils import parseaddr
+
class HeadersCheckMixin(object):
@@ -244,7 +249,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
msg.attach_alternative(html_content, "text/html")
msg.attach("an attachment.pdf", b"%PDF-1.4.%...", mimetype="application/pdf")
msg_str = msg.message().as_string()
- message = email.message_from_string(msg_str)
+ message = message_from_string(msg_str)
self.assertTrue(message.is_multipart())
self.assertEqual(message.get_content_type(), 'multipart/mixed')
self.assertEqual(message.get_default_type(), 'text/plain')
@@ -261,7 +266,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
# Unicode in file name
msg.attach("une pièce jointe.pdf", b"%PDF-1.4.%...", mimetype="application/pdf")
msg_str = msg.message().as_string()
- message = email.message_from_string(msg_str)
+ message = message_from_string(msg_str)
payload = message.get_payload()
self.assertEqual(payload[1].get_filename(), 'une pièce jointe.pdf')
@@ -689,7 +694,7 @@ class FileBackendTests(BaseEmailBackendTests, SimpleTestCase):
for filename in os.listdir(self.tmp_dir):
with open(os.path.join(self.tmp_dir, filename), 'r') as fp:
session = force_text(fp.read()).split('\n' + ('-' * 79) + '\n')
- messages.extend(email.message_from_string(force_str(m)) for m in session if m)
+ messages.extend(message_from_string(force_str(m)) for m in session if m)
return messages
def test_file_sessions(self):
@@ -700,7 +705,7 @@ class FileBackendTests(BaseEmailBackendTests, SimpleTestCase):
self.assertEqual(len(os.listdir(self.tmp_dir)), 1)
with open(os.path.join(self.tmp_dir, os.listdir(self.tmp_dir)[0])) as fp:
- message = email.message_from_file(fp)
+ message = message_from_file(fp)
self.assertEqual(message.get_content_type(), 'text/plain')
self.assertEqual(message.get('subject'), 'Subject')
self.assertEqual(message.get('from'), 'from@example.com')
@@ -742,7 +747,7 @@ class ConsoleBackendTests(BaseEmailBackendTests, SimpleTestCase):
def get_mailbox_content(self):
messages = force_text(self.stream.getvalue()).split('\n' + ('-' * 79) + '\n')
- return [email.message_from_string(force_str(m)) for m in messages if m]
+ return [message_from_string(force_str(m)) for m in messages if m]
def test_console_stream_kwarg(self):
"""
@@ -788,11 +793,8 @@ class FakeSMTPServer(smtpd.SMTPServer, threading.Thread):
self.sink_lock = threading.Lock()
def process_message(self, peer, mailfrom, rcpttos, data):
- m = email.message_from_string(data)
- if PY3:
- maddr = email.utils.parseaddr(m.get('from'))[1]
- else:
- maddr = email.Utils.parseaddr(m.get('from'))[1]
+ m = message_from_string(data)
+ maddr = parseaddr(m.get('from'))[1]
if mailfrom != maddr:
return "553 '%s' != '%s'" % (mailfrom, maddr)
with self.sink_lock:
diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py
index 0550aa2a34..37f59061ac 100644
--- a/tests/multiple_database/tests.py
+++ b/tests/multiple_database/tests.py
@@ -928,21 +928,21 @@ class ConnectionRouterTestCase(TestCase):
'multiple_database.tests.TestRouter',
'multiple_database.tests.WriteRouter'])
def test_router_init_default(self):
- router = ConnectionRouter()
- self.assertListEqual([r.__class__.__name__ for r in router.routers],
+ connection_router = ConnectionRouter()
+ self.assertListEqual([r.__class__.__name__ for r in connection_router.routers],
['TestRouter', 'WriteRouter'])
def test_router_init_arg(self):
- router = ConnectionRouter([
+ connection_router = ConnectionRouter([
'multiple_database.tests.TestRouter',
'multiple_database.tests.WriteRouter'
])
- self.assertListEqual([r.__class__.__name__ for r in router.routers],
+ self.assertListEqual([r.__class__.__name__ for r in connection_router.routers],
['TestRouter', 'WriteRouter'])
# Init with instances instead of strings
- router = ConnectionRouter([TestRouter(), WriteRouter()])
- self.assertListEqual([r.__class__.__name__ for r in router.routers],
+ connection_router = ConnectionRouter([TestRouter(), WriteRouter()])
+ self.assertListEqual([r.__class__.__name__ for r in connection_router.routers],
['TestRouter', 'WriteRouter'])