Showing
1 changed file
with
6 additions
and
6 deletions
| ... | ... | @@ -119,7 +119,7 @@ class CommentViewTests(CommentTestCase): |
| 119 | 119 | response = self.client.post("/post/", data, REMOTE_ADDR=address) |
| 120 | 120 | self.assertEqual(response.status_code, 302) |
| 121 | 121 | self.assertEqual(Comment.objects.count(), 1) |
| 122 | - c = Comment.objects.all()[0] | |
| 122 | + c = Comment.objects.first() | |
| 123 | 123 | self.assertEqual(c.ip_address, address) |
| 124 | 124 | self.assertEqual(c.comment, "This is my comment") |
| 125 | 125 | |
| ... | ... | @@ -136,7 +136,7 @@ class CommentViewTests(CommentTestCase): |
| 136 | 136 | response = self.client.post("/post/", data, REMOTE_ADDR=address) |
| 137 | 137 | self.assertEqual(response.status_code, 302) |
| 138 | 138 | self.assertEqual(Comment.objects.count(), 1) |
| 139 | - c = Comment.objects.all()[0] | |
| 139 | + c = Comment.objects.first() | |
| 140 | 140 | self.assertEqual(c.ip_address, address) |
| 141 | 141 | self.assertEqual(c.comment, "This is my comment") |
| 142 | 142 | |
| ... | ... | @@ -156,7 +156,7 @@ class CommentViewTests(CommentTestCase): |
| 156 | 156 | response = self.client.post("/post/", data, REMOTE_ADDR=address) |
| 157 | 157 | self.assertEqual(response.status_code, 302) |
| 158 | 158 | self.assertEqual(Comment.objects.count(), 1) |
| 159 | - c = Comment.objects.all()[0] | |
| 159 | + c = Comment.objects.first() | |
| 160 | 160 | # We trim the '::ffff:' bit off because it is an IPv4 addr |
| 161 | 161 | self.assertEqual(c.ip_address, address[7:]) |
| 162 | 162 | self.assertEqual(c.comment, "This is my comment") |
| ... | ... | @@ -169,7 +169,7 @@ class CommentViewTests(CommentTestCase): |
| 169 | 169 | response = self.client.post("/post/", data, REMOTE_ADDR="1.2.3.4") |
| 170 | 170 | self.assertEqual(response.status_code, 302) |
| 171 | 171 | self.assertEqual(Comment.objects.count(), 1) |
| 172 | - c = Comment.objects.all()[0] | |
| 172 | + c = Comment.objects.first() | |
| 173 | 173 | self.assertEqual(c.ip_address, "1.2.3.4") |
| 174 | 174 | u = User.objects.get(username='normaluser') |
| 175 | 175 | self.assertEqual(c.user, u) |
| ... | ... | @@ -255,7 +255,7 @@ class CommentViewTests(CommentTestCase): |
| 255 | 255 | |
| 256 | 256 | signals.comment_will_be_posted.connect(receive) |
| 257 | 257 | self.testCreateValidComment() |
| 258 | - c = Comment.objects.all()[0] | |
| 258 | + c = Comment.objects.first() | |
| 259 | 259 | self.assertFalse(c.is_public) |
| 260 | 260 | |
| 261 | 261 | def testCommentNext(self): |
| ... | ... | @@ -291,7 +291,7 @@ class CommentViewTests(CommentTestCase): |
| 291 | 291 | pk = int(match.group('pk')) |
| 292 | 292 | response = self.client.get(location) |
| 293 | 293 | self.assertTemplateUsed(response, "comments/posted.html") |
| 294 | - self.assertEqual(response.context[0]["comment"], Comment.objects.get(pk=pk)) | |
| 294 | + self.assertEqual(response.context["comment"], Comment.objects.get(pk=pk)) | |
| 295 | 295 | |
| 296 | 296 | def testCommentNextWithQueryString(self): |
| 297 | 297 | """ | ... | ... |
Please
register
or
login
to post a comment