From b1e33ceceda1e75ff68c7deed8f6659683a195d3 Mon Sep 17 00:00:00 2001 From: Dražen Odobašić Date: Fri, 11 Sep 2015 19:33:12 -0400 Subject: Fixed #23395 -- Limited line lengths to 119 characters. --- tests/model_forms/tests.py | 159 +++++++++++++++++++++++++++++++-------------- 1 file changed, 112 insertions(+), 47 deletions(-) (limited to 'tests/model_forms') diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 76f575ac7b..80dcf43be7 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -494,9 +494,12 @@ class ModelFormBaseTest(TestCase): self.assertHTMLEqual( str(SubclassMeta()), - """ - -""" + """ + + + + +""" ) def test_orderfields_form(self): @@ -509,8 +512,10 @@ class ModelFormBaseTest(TestCase): ['url', 'name']) self.assertHTMLEqual( str(OrderFields()), - """ -""" + """ + + +""" ) def test_orderfields2_form(self): @@ -894,7 +899,10 @@ class UniqueTest(TestCase): class Meta(PostForm.Meta): error_messages = { 'title': { - 'unique_for_date': "%(model_name)s's %(field_label)s not unique for %(date_field_label)s date.", + 'unique_for_date': ( + "%(model_name)s's %(field_label)s not unique " + "for %(date_field_label)s date." + ), } } @@ -993,9 +1001,12 @@ class ModelFormBasicTests(TestCase): f = BaseCategoryForm() self.assertHTMLEqual( str(f), - """ - -""" + """ + + + + +""" ) self.assertHTMLEqual( str(f.as_ul()), @@ -1025,7 +1036,9 @@ class ModelFormBasicTests(TestCase): 'headline': 'Your headline here', 'categories': [str(self.c1.id), str(self.c2.id)] }) - self.assertHTMLEqual(f.as_ul(), '''
  • Headline:
  • + self.assertHTMLEqual( + f.as_ul(), + '''
  • Headline:
  • Slug:
  • Pub date:
  • Writer:
    Use both first and last names.''') + self.assertHTMLEqual( + six.text_type(f), + '''Name:
    + Use both first and last names.''' + ) art = Article.objects.create( headline='Test article', @@ -1061,7 +1078,9 @@ class ModelFormBasicTests(TestCase): art_id_1 = art.id f = ArticleForm(auto_id=False, instance=art) - self.assertHTMLEqual(f.as_ul(), '''
  • Headline:
  • + self.assertHTMLEqual( + f.as_ul(), + '''
  • Headline:
  • Slug:
  • Pub date:
  • Writer:
  • -
  • +
  • + + self.assertHTMLEqual( + six.text_type(f), + '''Headline: Slug: Pub date: Writer:
  • + self.assertHTMLEqual( + f.as_ul(), + '''
  • Headline:
  • Slug:
  • Pub date:
  • Writer: + self.assertHTMLEqual( + six.text_type(f), + '''Headline: Pub date:''') # You can create a form over a subset of the available fields @@ -1249,9 +1281,12 @@ class ModelFormBasicTests(TestCase): 'slug': 'new-headline', 'pub_date': '1988-01-04' }, auto_id=False, instance=art) - self.assertHTMLEqual(f.as_ul(), '''
  • Headline:
  • + self.assertHTMLEqual( + f.as_ul(), + '''
  • Headline:
  • Slug:
  • -
  • Pub date:
  • ''') +
  • Pub date:
  • ''' + ) self.assertTrue(f.is_valid()) new_art = f.save() self.assertEqual(new_art.id, art.id) @@ -1337,7 +1372,9 @@ class ModelFormBasicTests(TestCase): # the data in the database when the form is instantiated. self.create_basic_data() f = ArticleForm(auto_id=False) - self.assertHTMLEqual(f.as_ul(), '''
  • Headline:
  • + self.assertHTMLEqual( + f.as_ul(), + '''
  • Headline:
  • Slug:
  • Pub date:
  • Writer:
  • + self.assertHTMLEqual( + f.as_ul(), + '''
  • Headline:
  • Slug:
  • Pub date:
  • Writer: + self.assertHTMLEqual( + form.as_p(), + '''

    -

    ''' % (self.w_woodward.pk, self.w_royko.pk)) +

    ''' % ( + self.w_woodward.pk, self.w_royko.pk, + ) + ) data = { 'writer': six.text_type(self.w_woodward.pk), @@ -1730,12 +1774,17 @@ class ModelOneToOneFieldTests(TestCase): self.assertEqual(six.text_type(instance), 'Bob Woodward is 65') form = WriterProfileForm(instance=instance) - self.assertHTMLEqual(form.as_p(), '''

    -

    ''' % (self.w_woodward.pk, self.w_royko.pk)) +

    ''' % ( + self.w_woodward.pk, self.w_royko.pk, + ) + ) def test_assignment_of_none(self): class AuthorForm(forms.ModelForm): @@ -2082,7 +2131,8 @@ class FileAndImageFieldTests(TestCase): self.assertEqual(instance.width, 16) self.assertEqual(instance.height, 16) - # Editing the instance without re-uploading the image should not affect the image or its width/height properties + # Editing the instance without re-uploading the image should not affect + # the image or its width/height properties. f = OptionalImageFileForm( data={'description': 'New Description'}, instance=instance) @@ -2123,7 +2173,10 @@ class ModelOtherFieldTests(SimpleTestCase): self.assertTrue(bif.is_valid()) bif = BigIntForm({'biggie': '-9223372036854775809'}) self.assertFalse(bif.is_valid()) - self.assertEqual(bif.errors, {'biggie': ['Ensure this value is greater than or equal to -9223372036854775808.']}) + self.assertEqual( + bif.errors, + {'biggie': ['Ensure this value is greater than or equal to -9223372036854775808.']} + ) bif = BigIntForm({'biggie': '9223372036854775807'}) self.assertTrue(bif.is_valid()) bif = BigIntForm({'biggie': '9223372036854775808'}) @@ -2203,8 +2256,11 @@ class OtherModelFormTests(TestCase): # Similar to a regular Form class you can define custom media to be used on # the ModelForm. f = ModelFormWithMedia() - self.assertHTMLEqual(six.text_type(f.media), ''' -''') + self.assertHTMLEqual( + six.text_type(f.media), + ''' +''' + ) def test_choices_type(self): # Choices on CharField and IntegerField @@ -2251,8 +2307,13 @@ class OtherModelFormTests(TestCase): self.assertEqual(list(CategoryForm.base_fields), ['description', 'url']) - self.assertHTMLEqual(six.text_type(CategoryForm()), ''' -''') + self.assertHTMLEqual( + six.text_type(CategoryForm()), + ''' + + +''' + ) # to_field_name should also work on ModelMultipleChoiceField ################## field = forms.ModelMultipleChoiceField(Inventory.objects.all(), to_field_name='barcode') @@ -2267,8 +2328,11 @@ class OtherModelFormTests(TestCase): def test_model_field_that_returns_none_to_exclude_itself_with_explicit_fields(self): self.assertEqual(list(CustomFieldForExclusionForm.base_fields), ['name']) - self.assertHTMLEqual(six.text_type(CustomFieldForExclusionForm()), - '''''') + self.assertHTMLEqual( + six.text_type(CustomFieldForExclusionForm()), + ''' +''' + ) def test_iterable_model_m2m(self): class ColourfulItemForm(forms.ModelForm): @@ -2298,19 +2362,20 @@ class OtherModelFormTests(TestCase): today_str = str(datetime.date.today()) self.assertHTMLEqual( form.as_p(), - """

    -

    - -

    -

    -

    -

    - + """ +

    +

    + +

    +

    +

    +

    + """.format(today_str) ) empty_data = { -- cgit v1.3