Skip to content

Commit cb7802d

Browse files
authored
nit: PEP 8 (mdn#3976)
Hi, Below several NIT ideas for small improvements in Django Tutorial Part 10 'Testing a Django web application' considering PEP 8 guidelines. In section 'LocalLibrary tests'/'Forms' there is: self.assertTrue(form.fields['renewal_date'].label == None or form.fields['renewal_date'].label == 'renewal date') While I believe there should be: self.assertTrue(form.fields['renewal_date'].label is None or form.fields['renewal_date'].label == 'renewal date') Explaination: Comparison with None performed with equality operator. That type of compression should be done with 'is'. PEP 8: comparison to None should be 'if cond is None'. In section 'LocalLibrary tests'/'Models' there is: def test_date_of_death_label(self): author=Author.objects.get(id=1) While I believe there should be: def test_date_of_death_label(self): author = Author.objects.get(id=1) Explaination: PEP 8: Missing whitespace around operator (=)
1 parent f1981f0 commit cb7802d

File tree

1 file changed

+2
-2
lines changed
  • files/en-us/learn/server-side/django/testing

1 file changed

+2
-2
lines changed

files/en-us/learn/server-side/django/testing/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ <h3 id="Models">Models</h3>
321321
self.assertEqual(field_label, 'first name')
322322

323323
def test_date_of_death_label(self):
324-
author=Author.objects.get(id=1)
324+
author = Author.objects.get(id=1)
325325
field_label = author._meta.get_field('date_of_death').verbose_name
326326
self.assertEqual(field_label, 'died')
327327

@@ -436,7 +436,7 @@ <h3 id="Forms">Forms</h3>
436436
class RenewBookFormTest(TestCase):
437437
    def test_renew_form_date_field_label(self):
438438
        form = RenewBookForm()
439-
        self.assertTrue(form.fields['renewal_date'].label == None or form.fields['renewal_date'].label == 'renewal date')
439+
        self.assertTrue(form.fields['renewal_date'].label is None or form.fields['renewal_date'].label == 'renewal date')
440440

441441
    def test_renew_form_date_field_help_text(self):
442442
        form = RenewBookForm()

0 commit comments

Comments
 (0)