summaryrefslogtreecommitdiff
path: root/tests/generic_views
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-10-19 08:31:38 -0400
committerTim Graham <timograham@gmail.com>2013-10-19 08:31:38 -0400
commit96d1d4e29275f4f5900f0725975d2ad0a4d05816 (patch)
tree17b846e3b77f68fbb3b1dc7a2ff413f574c62ce1 /tests/generic_views
parent5f52590368063fc8284e23be492d83ba751f66bf (diff)
Removed unused local variables in tests.
Diffstat (limited to 'tests/generic_views')
-rw-r--r--tests/generic_views/test_base.py4
-rw-r--r--tests/generic_views/test_dates.py4
-rw-r--r--tests/generic_views/test_edit.py40
3 files changed, 23 insertions, 25 deletions
diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py
index 5dd6815d05..eafa61a271 100644
--- a/tests/generic_views/test_base.py
+++ b/tests/generic_views/test_base.py
@@ -76,7 +76,7 @@ class ViewTest(unittest.TestCase):
Test that a view can't be accidentally instantiated before deployment
"""
try:
- view = SimpleView(key='value').as_view()
+ SimpleView(key='value').as_view()
self.fail('Should not be able to instantiate a view')
except AttributeError:
pass
@@ -86,7 +86,7 @@ class ViewTest(unittest.TestCase):
Test that a view can't be accidentally instantiated before deployment
"""
try:
- view = SimpleView.as_view('value')
+ SimpleView.as_view('value')
self.fail('Should not be able to use non-keyword arguments instantiating a view')
except TypeError:
pass
diff --git a/tests/generic_views/test_dates.py b/tests/generic_views/test_dates.py
index 3e6f8a2c1f..5c887eaac1 100644
--- a/tests/generic_views/test_dates.py
+++ b/tests/generic_views/test_dates.py
@@ -12,7 +12,7 @@ from .models import Book, BookSigning
def _make_books(n, base_date):
for i in range(n):
- b = Book.objects.create(
+ Book.objects.create(
name='Book %d' % i,
slug='book-%d' % i,
pages=100+i,
@@ -158,7 +158,7 @@ class YearArchiveViewTests(TestCase):
def test_year_view_allow_future(self):
# Create a new book in the future
year = datetime.date.today().year + 1
- b = Book.objects.create(name="The New New Testement", pages=600, pubdate=datetime.date(year, 1, 1))
+ Book.objects.create(name="The New New Testement", pages=600, pubdate=datetime.date(year, 1, 1))
res = self.client.get('/dates/books/%s/' % year)
self.assertEqual(res.status_code, 404)
diff --git a/tests/generic_views/test_edit.py b/tests/generic_views/test_edit.py
index 87a2e346e4..be26a14adf 100644
--- a/tests/generic_views/test_edit.py
+++ b/tests/generic_views/test_edit.py
@@ -122,15 +122,15 @@ class CreateViewTests(TestCase):
def test_create_without_redirect(self):
try:
- res = self.client.post('/edit/authors/create/naive/',
- {'name': 'Randall Munroe', 'slug': 'randall-munroe'})
+ self.client.post('/edit/authors/create/naive/',
+ {'name': 'Randall Munroe', 'slug': 'randall-munroe'})
self.fail('Should raise exception -- No redirect URL provided, and no get_absolute_url provided')
except ImproperlyConfigured:
pass
def test_create_restricted(self):
res = self.client.post('/edit/authors/create/restricted/',
- {'name': 'Randall Munroe', 'slug': 'randall-munroe'})
+ {'name': 'Randall Munroe', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/accounts/login/?next=/edit/authors/create/restricted/')
@@ -278,16 +278,15 @@ class UpdateViewTests(TestCase):
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
def test_update_without_redirect(self):
- try:
- a = Author.objects.create(
- name='Randall Munroe',
- slug='randall-munroe',
- )
- res = self.client.post('/edit/author/%d/update/naive/' % a.pk,
+ a = Author.objects.create(
+ name='Randall Munroe',
+ slug='randall-munroe',
+ )
+ # Should raise exception -- No redirect URL provided, and no
+ # get_absolute_url provided
+ with self.assertRaises(ImproperlyConfigured):
+ self.client.post('/edit/author/%d/update/naive/' % a.pk,
{'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
- self.fail('Should raise exception -- No redirect URL provided, and no get_absolute_url provided')
- except ImproperlyConfigured:
- pass
def test_update_get_object(self):
a = Author.objects.create(
@@ -365,12 +364,11 @@ class DeleteViewTests(TestCase):
self.assertQuerysetEqual(Author.objects.all(), [])
def test_delete_without_redirect(self):
- try:
- a = Author.objects.create(
- name='Randall Munroe',
- slug='randall-munroe',
- )
- res = self.client.post('/edit/author/%d/delete/naive/' % a.pk)
- self.fail('Should raise exception -- No redirect URL provided, and no get_absolute_url provided')
- except ImproperlyConfigured:
- pass
+ a = Author.objects.create(
+ name='Randall Munroe',
+ slug='randall-munroe',
+ )
+ # Should raise exception -- No redirect URL provided, and no
+ # get_absolute_url provided
+ with self.assertRaises(ImproperlyConfigured):
+ self.client.post('/edit/author/%d/delete/naive/' % a.pk)