summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-10-10 09:35:56 -0400
committerTim Graham <timograham@gmail.com>2013-10-10 09:35:56 -0400
commitcec11a3336c730e6dc2f1966fee749cc830e97c0 (patch)
tree014c34809c0d39ca63c711e6168d297b9de013b3 /tests
parentff9e8eccf89fc1dce441736c39dcb6e218ca8940 (diff)
Used "is" for comparisons with None.
Diffstat (limited to 'tests')
-rw-r--r--tests/basic/tests.py4
-rw-r--r--tests/comment_tests/tests/test_comment_view.py14
-rw-r--r--tests/signals_regress/tests.py4
3 files changed, 11 insertions, 11 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py
index 0d766dde2b..5c1ed0726a 100644
--- a/tests/basic/tests.py
+++ b/tests/basic/tests.py
@@ -33,7 +33,7 @@ class ModelTest(TestCase):
a.save()
# Now it has an ID.
- self.assertTrue(a.id != None)
+ self.assertTrue(a.id is not None)
# Models have a pk property that is an alias for the primary key
# attribute (by default, the 'id' attribute).
@@ -585,7 +585,7 @@ class ModelTest(TestCase):
f3 = Field()
self.assertTrue(f2 < f1)
self.assertTrue(f3 > f1)
- self.assertFalse(f1 == None)
+ self.assertFalse(f1 is None)
self.assertFalse(f2 in (None, 1, ''))
def test_extra_method_select_argument_with_dashes_and_values(self):
diff --git a/tests/comment_tests/tests/test_comment_view.py b/tests/comment_tests/tests/test_comment_view.py
index 19d7c1d16b..731776a1e2 100644
--- a/tests/comment_tests/tests/test_comment_view.py
+++ b/tests/comment_tests/tests/test_comment_view.py
@@ -243,21 +243,21 @@ class CommentViewTests(CommentTestCase):
response = self.client.post("/post/", data)
location = response["Location"]
match = post_redirect_re.match(location)
- self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
+ self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
data["next"] = "/somewhere/else/"
data["comment"] = "This is another comment"
response = self.client.post("/post/", data)
location = response["Location"]
match = re.search(r"^http://testserver/somewhere/else/\?c=\d+$", location)
- self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
+ self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
data["next"] = "http://badserver/somewhere/else/"
data["comment"] = "This is another comment with an unsafe next url"
response = self.client.post("/post/", data)
location = response["Location"]
match = post_redirect_re.match(location)
- self.assertTrue(match != None, "Unsafe redirection to: %s" % location)
+ self.assertTrue(match is not None, "Unsafe redirection to: %s" % location)
def testCommentDoneView(self):
a = Article.objects.get(pk=1)
@@ -265,7 +265,7 @@ class CommentViewTests(CommentTestCase):
response = self.client.post("/post/", data)
location = response["Location"]
match = post_redirect_re.match(location)
- self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
+ self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
pk = int(match.group('pk'))
response = self.client.get(location)
self.assertTemplateUsed(response, "comments/posted.html")
@@ -282,7 +282,7 @@ class CommentViewTests(CommentTestCase):
response = self.client.post("/post/", data)
location = response["Location"]
match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+$", location)
- self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
+ self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
def testCommentPostRedirectWithInvalidIntegerPK(self):
"""
@@ -311,7 +311,7 @@ class CommentViewTests(CommentTestCase):
response = self.client.post("/post/", data)
location = response["Location"]
match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+#baz$", location)
- self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
+ self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
# Without a query string
a = Article.objects.get(pk=1)
@@ -321,4 +321,4 @@ class CommentViewTests(CommentTestCase):
response = self.client.post("/post/", data)
location = response["Location"]
match = re.search(r"^http://testserver/somewhere/else/\?c=\d+#baz$", location)
- self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
+ self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
diff --git a/tests/signals_regress/tests.py b/tests/signals_regress/tests.py
index 2c9858efda..328e699b9d 100644
--- a/tests/signals_regress/tests.py
+++ b/tests/signals_regress/tests.py
@@ -34,11 +34,11 @@ class SignalsRegressTests(TestCase):
def pre_delete_test(self, signal, sender, instance, **kwargs):
self.signal_output.append('pre_save signal, %s' % instance)
- self.signal_output.append('instance.id is not None: %s' % (instance.id != None))
+ self.signal_output.append('instance.id is not None: %s' % (instance.id is not None))
def post_delete_test(self, signal, sender, instance, **kwargs):
self.signal_output.append('post_delete signal, %s' % instance)
- self.signal_output.append('instance.id is not None: %s' % (instance.id != None))
+ self.signal_output.append('instance.id is not None: %s' % (instance.id is not None))
def setUp(self):
self.signal_output = []