diff options
| author | Tim Graham <timograham@gmail.com> | 2019-01-02 18:18:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-02 18:18:19 -0500 |
| commit | 0004daa536890fdb389c895baaa21bea6a1f7073 (patch) | |
| tree | 9f66a0ce81466d8fa7043e70f0d96b9cc3350473 /tests | |
| parent | 5bbf31634faad13658dc7bcaeb8139d8625e4349 (diff) | |
Used 4 space hanging indent for dictionaries.
Thanks Mariusz Felisiak for auditing.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_filters/tests.py | 18 | ||||
| -rw-r--r-- | tests/admin_views/admin.py | 12 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 59 | ||||
| -rw-r--r-- | tests/fixtures/tests.py | 22 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 10 | ||||
| -rw-r--r-- | tests/gis_tests/geoapp/sitemaps.py | 7 | ||||
| -rw-r--r-- | tests/gis_tests/geoapp/test_functions.py | 14 | ||||
| -rw-r--r-- | tests/gis_tests/geogapp/tests.py | 10 | ||||
| -rw-r--r-- | tests/gis_tests/layermap/models.py | 29 | ||||
| -rw-r--r-- | tests/gis_tests/layermap/tests.py | 14 | ||||
| -rw-r--r-- | tests/introspection/tests.py | 8 | ||||
| -rw-r--r-- | tests/logging_tests/tests.py | 7 | ||||
| -rw-r--r-- | tests/mail/tests.py | 10 | ||||
| -rw-r--r-- | tests/model_forms/tests.py | 28 | ||||
| -rw-r--r-- | tests/model_formsets_regress/tests.py | 10 | ||||
| -rw-r--r-- | tests/requests/tests.py | 132 | ||||
| -rw-r--r-- | tests/timezones/tests.py | 31 | ||||
| -rw-r--r-- | tests/utils_tests/test_datastructures.py | 11 | ||||
| -rw-r--r-- | tests/view_tests/tests/test_debug.py | 12 |
19 files changed, 260 insertions, 184 deletions
diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py index 01e1076141..4ff7d012e5 100644 --- a/tests/admin_filters/tests.py +++ b/tests/admin_filters/tests.py @@ -322,8 +322,10 @@ class ListFiltersTests(TestCase): request.user = self.alfred changelist = modeladmin.get_changelist(request) - request = self.request_factory.get('/', {'date_registered__gte': self.today, - 'date_registered__lt': self.tomorrow}) + request = self.request_factory.get('/', { + 'date_registered__gte': self.today, + 'date_registered__lt': self.tomorrow}, + ) request.user = self.alfred changelist = modeladmin.get_changelist_instance(request) @@ -344,8 +346,10 @@ class ListFiltersTests(TestCase): ) ) - request = self.request_factory.get('/', {'date_registered__gte': self.today.replace(day=1), - 'date_registered__lt': self.next_month}) + request = self.request_factory.get('/', { + 'date_registered__gte': self.today.replace(day=1), + 'date_registered__lt': self.next_month}, + ) request.user = self.alfred changelist = modeladmin.get_changelist_instance(request) @@ -370,8 +374,10 @@ class ListFiltersTests(TestCase): ) ) - request = self.request_factory.get('/', {'date_registered__gte': self.today.replace(month=1, day=1), - 'date_registered__lt': self.next_year}) + request = self.request_factory.get('/', { + 'date_registered__gte': self.today.replace(month=1, day=1), + 'date_registered__lt': self.next_year}, + ) request.user = self.alfred changelist = modeladmin.get_changelist_instance(request) diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 5c4151c270..d09e7fa084 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -730,16 +730,20 @@ class RelatedPrepopulatedInline1(admin.StackedInline): model = RelatedPrepopulated extra = 1 autocomplete_fields = ['fk', 'm2m'] - prepopulated_fields = {'slug1': ['name', 'pubdate'], - 'slug2': ['status', 'name']} + prepopulated_fields = { + 'slug1': ['name', 'pubdate'], + 'slug2': ['status', 'name'], + } class RelatedPrepopulatedInline2(admin.TabularInline): model = RelatedPrepopulated extra = 1 autocomplete_fields = ['fk', 'm2m'] - prepopulated_fields = {'slug1': ['name', 'pubdate'], - 'slug2': ['status', 'name']} + prepopulated_fields = { + 'slug1': ['name', 'pubdate'], + 'slug2': ['status', 'name'], + } class RelatedPrepopulatedInline3(admin.TabularInline): diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index d4bd873d2a..93a93454d9 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1650,11 +1650,12 @@ class AdminViewPermissionsTest(TestCase): def test_add_view(self): """Test add view restricts access and actually adds items.""" - add_dict = {'title': 'Døm ikke', - 'content': '<p>great article</p>', - 'date_0': '2008-03-18', 'date_1': '10:54:39', - 'section': self.s1.pk} - + add_dict = { + 'title': 'Døm ikke', + 'content': '<p>great article</p>', + 'date_0': '2008-03-18', 'date_1': '10:54:39', + 'section': self.s1.pk, + } # Change User should not have access to add articles self.client.force_login(self.changeuser) # make sure the view removes test cookie @@ -1754,10 +1755,12 @@ class AdminViewPermissionsTest(TestCase): def test_change_view(self): """Change view should restrict access and allow users to edit items.""" - change_dict = {'title': 'Ikke fordømt', - 'content': '<p>edited article</p>', - 'date_0': '2008-03-18', 'date_1': '10:54:39', - 'section': self.s1.pk} + change_dict = { + 'title': 'Ikke fordømt', + 'content': '<p>edited article</p>', + 'date_0': '2008-03-18', 'date_1': '10:54:39', + 'section': self.s1.pk, + } article_change_url = reverse('admin:admin_views_article_change', args=(self.a1.pk,)) article_changelist_url = reverse('admin:admin_views_article_changelist') @@ -6023,15 +6026,16 @@ class AdminViewOnSiteTests(TestCase): # The form validation should fail because 'some_required_info' is # not included on the parent form, and the family_name of the parent # does not match that of the child - post_data = {"family_name": "Test1", - "dependentchild_set-TOTAL_FORMS": "1", - "dependentchild_set-INITIAL_FORMS": "0", - "dependentchild_set-MAX_NUM_FORMS": "1", - "dependentchild_set-0-id": "", - "dependentchild_set-0-parent": "", - "dependentchild_set-0-family_name": "Test2"} - response = self.client.post(reverse('admin:admin_views_parentwithdependentchildren_add'), - post_data) + post_data = { + 'family_name': 'Test1', + 'dependentchild_set-TOTAL_FORMS': '1', + 'dependentchild_set-INITIAL_FORMS': '0', + 'dependentchild_set-MAX_NUM_FORMS': '1', + 'dependentchild_set-0-id': '', + 'dependentchild_set-0-parent': '', + 'dependentchild_set-0-family_name': 'Test2', + } + response = self.client.post(reverse('admin:admin_views_parentwithdependentchildren_add'), post_data) self.assertFormError(response, 'adminform', 'some_required_info', ['This field is required.']) msg = "The form 'adminform' in context 0 does not contain the non-field error 'Error'" with self.assertRaisesMessage(AssertionError, msg): @@ -6050,18 +6054,19 @@ class AdminViewOnSiteTests(TestCase): Verifying that if the parent form fails validation, the inlines also run validation even if validation is contingent on parent form data """ - pwdc = ParentWithDependentChildren.objects.create(some_required_info=6, - family_name="Test1") + pwdc = ParentWithDependentChildren.objects.create(some_required_info=6, family_name='Test1') # The form validation should fail because 'some_required_info' is # not included on the parent form, and the family_name of the parent # does not match that of the child - post_data = {"family_name": "Test2", - "dependentchild_set-TOTAL_FORMS": "1", - "dependentchild_set-INITIAL_FORMS": "0", - "dependentchild_set-MAX_NUM_FORMS": "1", - "dependentchild_set-0-id": "", - "dependentchild_set-0-parent": str(pwdc.id), - "dependentchild_set-0-family_name": "Test1"} + post_data = { + 'family_name': 'Test2', + 'dependentchild_set-TOTAL_FORMS': '1', + 'dependentchild_set-INITIAL_FORMS': '0', + 'dependentchild_set-MAX_NUM_FORMS': '1', + 'dependentchild_set-0-id': '', + 'dependentchild_set-0-parent': str(pwdc.id), + 'dependentchild_set-0-family_name': 'Test1', + } response = self.client.post( reverse('admin:admin_views_parentwithdependentchildren_change', args=(pwdc.id,)), post_data ) diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index 37b21fa296..059b0ed80a 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -53,15 +53,19 @@ class DumpDataAssertMixin: use_base_manager=False, exclude_list=[], primary_keys=''): new_io = StringIO() filename = filename and os.path.join(tempfile.gettempdir(), filename) - management.call_command('dumpdata', *args, **{'format': format, - 'stdout': new_io, - 'stderr': new_io, - 'output': filename, - 'use_natural_foreign_keys': natural_foreign_keys, - 'use_natural_primary_keys': natural_primary_keys, - 'use_base_manager': use_base_manager, - 'exclude': exclude_list, - 'primary_keys': primary_keys}) + management.call_command( + 'dumpdata', + *args, + format=format, + stdout=new_io, + stderr=new_io, + output=filename, + use_natural_foreign_keys=natural_foreign_keys, + use_natural_primary_keys=natural_primary_keys, + use_base_manager=use_base_manager, + exclude=exclude_list, + primary_keys=primary_keys, + ) if filename: with open(filename, "r") as f: command_output = f.read() diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index bad24b5230..d4e421d6ac 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -2872,8 +2872,14 @@ Good luck picking a username that doesn't already exist.</p> self.assertEqual(form.errors, {'name': ['bad value not allowed']}) form = NameForm(data={'name': ['should be overly', 'long for the field names']}) self.assertFalse(form.is_valid()) - self.assertEqual(form.errors, {'name': ['Ensure this value has at most 10 characters (it has 16).', - 'Ensure this value has at most 10 characters (it has 24).']}) + self.assertEqual( + form.errors, { + 'name': [ + 'Ensure this value has at most 10 characters (it has 16).', + 'Ensure this value has at most 10 characters (it has 24).', + ], + } + ) form = NameForm(data={'name': ['fname', 'lname']}) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data, {'name': 'fname lname'}) diff --git a/tests/gis_tests/geoapp/sitemaps.py b/tests/gis_tests/geoapp/sitemaps.py index 1a3101290a..91e5d82bb4 100644 --- a/tests/gis_tests/geoapp/sitemaps.py +++ b/tests/gis_tests/geoapp/sitemaps.py @@ -2,6 +2,7 @@ from django.contrib.gis.sitemaps import KMLSitemap, KMZSitemap from .models import City, Country -sitemaps = {'kml': KMLSitemap([City, Country]), - 'kmz': KMZSitemap([City, Country]), - } +sitemaps = { + 'kml': KMLSitemap([City, Country]), + 'kmz': KMZSitemap([City, Country]), +} diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 4b09cebb3e..e7eec26dd6 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -365,15 +365,17 @@ class GISFunctionsTests(FuncTestMixin, TestCase): if oracle: # SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_POINTONSURFACE(GEOAPP_COUNTRY.MPOLY, 0.05)) # FROM GEOAPP_COUNTRY; - ref = {'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326), - 'Texas': fromstr('POINT (-103.002434 36.500397)', srid=4326), - } + ref = { + 'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326), + 'Texas': fromstr('POINT (-103.002434 36.500397)', srid=4326), + } else: # Using GEOSGeometry to compute the reference point on surface values # -- since PostGIS also uses GEOS these should be the same. - ref = {'New Zealand': Country.objects.get(name='New Zealand').mpoly.point_on_surface, - 'Texas': Country.objects.get(name='Texas').mpoly.point_on_surface - } + ref = { + 'New Zealand': Country.objects.get(name='New Zealand').mpoly.point_on_surface, + 'Texas': Country.objects.get(name='Texas').mpoly.point_on_surface + } qs = Country.objects.annotate(point_on_surface=functions.PointOnSurface('mpoly')) for country in qs: diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py index 7f6c441ba5..9cf8ab92f7 100644 --- a/tests/gis_tests/geogapp/tests.py +++ b/tests/gis_tests/geogapp/tests.py @@ -66,11 +66,11 @@ class GeographyTest(TestCase): # Getting the shapefile and mapping dictionary. shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data')) co_shp = os.path.join(shp_path, 'counties', 'counties.shp') - co_mapping = {'name': 'Name', - 'state': 'State', - 'mpoly': 'MULTIPOLYGON', - } - + co_mapping = { + 'name': 'Name', + 'state': 'State', + 'mpoly': 'MULTIPOLYGON', + } # Reference county names, number of polygons, and state names. names = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo'] num_polys = [1, 2, 1, 19, 1] # Number of polygons for each. diff --git a/tests/gis_tests/layermap/models.py b/tests/gis_tests/layermap/models.py index de1dd6c944..7c029a0ee8 100644 --- a/tests/gis_tests/layermap/models.py +++ b/tests/gis_tests/layermap/models.py @@ -77,18 +77,21 @@ co_mapping = { 'mpoly': 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS. } -cofeat_mapping = {'name': 'Name', - 'poly': 'POLYGON', - } +cofeat_mapping = { + 'name': 'Name', + 'poly': 'POLYGON', +} -city_mapping = {'name': 'Name', - 'population': 'Population', - 'density': 'Density', - 'dt': 'Created', - 'point': 'POINT', - } +city_mapping = { + 'name': 'Name', + 'population': 'Population', + 'density': 'Density', + 'dt': 'Created', + 'point': 'POINT', +} -inter_mapping = {'name': 'Name', - 'length': 'Length', - 'path': 'LINESTRING', - } +inter_mapping = { + 'name': 'Name', + 'length': 'Length', + 'path': 'LINESTRING', +} diff --git a/tests/gis_tests/layermap/tests.py b/tests/gis_tests/layermap/tests.py index a1b288eafa..460d6f6a4d 100644 --- a/tests/gis_tests/layermap/tests.py +++ b/tests/gis_tests/layermap/tests.py @@ -261,13 +261,13 @@ class LayerMapTest(TestCase): def test_model_inheritance(self): "Tests LayerMapping on inherited models. See #12093." - icity_mapping = {'name': 'Name', - 'population': 'Population', - 'density': 'Density', - 'point': 'POINT', - 'dt': 'Created', - } - + icity_mapping = { + 'name': 'Name', + 'population': 'Population', + 'density': 'Density', + 'point': 'POINT', + 'dt': 'Created', + } # Parent model has geometry field. lm1 = LayerMapping(ICity1, city_shp, icity_mapping) lm1.save() diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py index c61720d12b..a616ee0f98 100644 --- a/tests/introspection/tests.py +++ b/tests/introspection/tests.py @@ -163,10 +163,10 @@ class IntrospectionTests(TransactionTestCase): def test_get_key_columns(self): with connection.cursor() as cursor: key_columns = connection.introspection.get_key_columns(cursor, Article._meta.db_table) - self.assertEqual( - set(key_columns), - {('reporter_id', Reporter._meta.db_table, 'id'), - ('response_to_id', Article._meta.db_table, 'id')}) + self.assertEqual(set(key_columns), { + ('reporter_id', Reporter._meta.db_table, 'id'), + ('response_to_id', Article._meta.db_table, 'id'), + }) def test_get_primary_key_column(self): with connection.cursor() as cursor: diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py index 37010ab7d0..3ab905eab6 100644 --- a/tests/logging_tests/tests.py +++ b/tests/logging_tests/tests.py @@ -537,9 +537,10 @@ format=%(message)s self.temp_file = NamedTemporaryFile() self.temp_file.write(logging_conf.encode()) self.temp_file.flush() - sdict = {'LOGGING_CONFIG': '"logging.config.fileConfig"', - 'LOGGING': 'r"%s"' % self.temp_file.name} - self.write_settings('settings.py', sdict=sdict) + self.write_settings('settings.py', sdict={ + 'LOGGING_CONFIG': '"logging.config.fileConfig"', + 'LOGGING': 'r"%s"' % self.temp_file.name, + }) def tearDown(self): self.temp_file.close() diff --git a/tests/mail/tests.py b/tests/mail/tests.py index f0f91e7b40..f06e053074 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -323,9 +323,13 @@ class MailTests(HeadersCheckMixin, SimpleTestCase): ) def test_unicode_headers(self): - email = EmailMessage("Gżegżółka", "Content", "from@example.com", ["to@example.com"], - headers={"Sender": '"Firstname Sürname" <sender@example.com>', - "Comments": 'My Sürname is non-ASCII'}) + email = EmailMessage( + 'Gżegżółka', 'Content', 'from@example.com', ['to@example.com'], + headers={ + 'Sender': '"Firstname Sürname" <sender@example.com>', + 'Comments': 'My Sürname is non-ASCII', + }, + ) message = email.message() self.assertEqual(message['Subject'], '=?utf-8?b?R8W8ZWfFvMOzxYJrYQ==?=') self.assertEqual(message['Sender'], '=?utf-8?q?Firstname_S=C3=BCrname?= <sender@example.com>') diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 77075e52f9..f4f3169bc1 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1297,9 +1297,11 @@ class ModelFormBasicTests(TestCase): def test_basic_creation(self): self.assertEqual(Category.objects.count(), 0) - f = BaseCategoryForm({'name': 'Entertainment', - 'slug': 'entertainment', - 'url': 'entertainment'}) + f = BaseCategoryForm({ + 'name': 'Entertainment', + 'slug': 'entertainment', + 'url': 'entertainment', + }) self.assertTrue(f.is_valid()) self.assertEqual(f.cleaned_data['name'], 'Entertainment') self.assertEqual(f.cleaned_data['slug'], 'entertainment') @@ -1712,15 +1714,23 @@ class ModelMultipleChoiceFieldTests(TestCase): person1 = Writer.objects.create(name="Person 1") person2 = Writer.objects.create(name="Person 2") - form = WriterForm(initial={'persons': [person1, person2]}, - data={'initial-persons': [str(person1.pk), str(person2.pk)], - 'persons': [str(person1.pk), str(person2.pk)]}) + form = WriterForm( + initial={'persons': [person1, person2]}, + data={ + 'initial-persons': [str(person1.pk), str(person2.pk)], + 'persons': [str(person1.pk), str(person2.pk)], + }, + ) self.assertTrue(form.is_valid()) self.assertFalse(form.has_changed()) - form = WriterForm(initial={'persons': [person1, person2]}, - data={'initial-persons': [str(person1.pk), str(person2.pk)], - 'persons': [str(person2.pk)]}) + form = WriterForm( + initial={'persons': [person1, person2]}, + data={ + 'initial-persons': [str(person1.pk), str(person2.pk)], + 'persons': [str(person2.pk)], + }, + ) self.assertTrue(form.is_valid()) self.assertTrue(form.has_changed()) diff --git a/tests/model_formsets_regress/tests.py b/tests/model_formsets_regress/tests.py index 0f86bbdb06..2232977481 100644 --- a/tests/model_formsets_regress/tests.py +++ b/tests/model_formsets_regress/tests.py @@ -296,10 +296,12 @@ class FormsetTests(TestCase): def test_extraneous_query_is_not_run(self): Formset = modelformset_factory(Network, fields="__all__") - data = {'test-TOTAL_FORMS': '1', - 'test-INITIAL_FORMS': '0', - 'test-MAX_NUM_FORMS': '', - 'test-0-name': 'Random Place'} + data = { + 'test-TOTAL_FORMS': '1', + 'test-INITIAL_FORMS': '0', + 'test-MAX_NUM_FORMS': '', + 'test-0-name': 'Random Place', + } with self.assertNumQueries(1): formset = Formset(data, prefix="test") formset.save() diff --git a/tests/requests/tests.py b/tests/requests/tests.py index 45e33ea651..c5efdad3c7 100644 --- a/tests/requests/tests.py +++ b/tests/requests/tests.py @@ -238,10 +238,12 @@ class RequestsTests(SimpleTestCase): def test_stream(self): payload = FakePayload('name=value') - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload}, + ) self.assertEqual(request.read(), b'name=value') def test_read_after_value(self): @@ -250,10 +252,12 @@ class RequestsTests(SimpleTestCase): POST or body. """ payload = FakePayload('name=value') - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload, + }) self.assertEqual(request.POST, {'name': ['value']}) self.assertEqual(request.body, b'name=value') self.assertEqual(request.read(), b'name=value') @@ -264,10 +268,12 @@ class RequestsTests(SimpleTestCase): from request. """ payload = FakePayload('name=value') - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload, + }) self.assertEqual(request.read(2), b'na') with self.assertRaises(RawPostDataException): request.body @@ -310,10 +316,12 @@ class RequestsTests(SimpleTestCase): 'value', '--boundary--' ''])) - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'multipart/form-data; boundary=boundary', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'multipart/form-data; boundary=boundary', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload, + }) self.assertEqual(request.POST, {'name': ['value']}) with self.assertRaises(RawPostDataException): request.body @@ -334,10 +342,12 @@ class RequestsTests(SimpleTestCase): b'--boundary--' b'']) payload = FakePayload(payload_data) - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'multipart/related; boundary=boundary', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'multipart/related; boundary=boundary', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload, + }) self.assertEqual(request.POST, {}) self.assertEqual(request.body, payload_data) @@ -356,18 +366,22 @@ class RequestsTests(SimpleTestCase): 'value', '--boundary--' ''])) - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'multipart/form-data; boundary=boundary', - 'CONTENT_LENGTH': 0, - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'multipart/form-data; boundary=boundary', + 'CONTENT_LENGTH': 0, + 'wsgi.input': payload, + }) self.assertEqual(request.POST, {}) def test_POST_binary_only(self): payload = b'\r\n\x01\x00\x00\x00ab\x00\x00\xcd\xcc,@' - environ = {'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'application/octet-stream', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': BytesIO(payload)} + environ = { + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'application/octet-stream', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': BytesIO(payload), + } request = WSGIRequest(environ) self.assertEqual(request.POST, {}) self.assertEqual(request.FILES, {}) @@ -382,10 +396,12 @@ class RequestsTests(SimpleTestCase): def test_read_by_lines(self): payload = FakePayload('name=value') - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload, + }) self.assertEqual(list(request), [b'name=value']) def test_POST_after_body_read(self): @@ -393,10 +409,12 @@ class RequestsTests(SimpleTestCase): POST should be populated even if body is read first """ payload = FakePayload('name=value') - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload, + }) request.body # evaluate self.assertEqual(request.POST, {'name': ['value']}) @@ -406,10 +424,12 @@ class RequestsTests(SimpleTestCase): the stream is read second. """ payload = FakePayload('name=value') - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload, + }) request.body # evaluate self.assertEqual(request.read(1), b'n') self.assertEqual(request.POST, {'name': ['value']}) @@ -426,10 +446,12 @@ class RequestsTests(SimpleTestCase): 'value', '--boundary--' ''])) - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'multipart/form-data; boundary=boundary', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload}) + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'multipart/form-data; boundary=boundary', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': payload, + }) request.body # evaluate # Consume enough data to mess up the parsing: self.assertEqual(request.read(13), b'--boundary\r\nC') @@ -464,11 +486,12 @@ class RequestsTests(SimpleTestCase): raise IOError("kaboom!") payload = b'name=value' - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': ExplodingBytesIO(payload)}) - + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': ExplodingBytesIO(payload), + }) with self.assertRaises(UnreadablePostError): request.body @@ -504,11 +527,12 @@ class RequestsTests(SimpleTestCase): raise IOError("kaboom!") payload = b'x' - request = WSGIRequest({'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'multipart/form-data; boundary=foo_', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': ExplodingBytesIO(payload)}) - + request = WSGIRequest({ + 'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'multipart/form-data; boundary=foo_', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': ExplodingBytesIO(payload), + }) with self.assertRaises(UnreadablePostError): request.FILES diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py index 42be78ae25..06ac51594c 100644 --- a/tests/timezones/tests.py +++ b/tests/timezones/tests.py @@ -866,14 +866,18 @@ class TemplateTests(SimpleTestCase): # Use a pytz timezone as argument tpl = Template("{% load tz %}{{ dt|timezone:tz }}") - ctx = Context({'dt': datetime.datetime(2011, 9, 1, 13, 20, 30), - 'tz': pytz.timezone('Europe/Paris')}) + ctx = Context({ + 'dt': datetime.datetime(2011, 9, 1, 13, 20, 30), + 'tz': pytz.timezone('Europe/Paris'), + }) self.assertEqual(tpl.render(ctx), "2011-09-01T12:20:30+02:00") # Use a pytz timezone name as argument tpl = Template("{% load tz %}{{ dt|timezone:'Europe/Paris' }}") - ctx = Context({'dt': datetime.datetime(2011, 9, 1, 13, 20, 30), - 'tz': pytz.timezone('Europe/Paris')}) + ctx = Context({ + 'dt': datetime.datetime(2011, 9, 1, 13, 20, 30), + 'tz': pytz.timezone('Europe/Paris'), + }) self.assertEqual(tpl.render(ctx), "2011-09-01T12:20:30+02:00") def test_localtime_templatetag_invalid_argument(self): @@ -913,8 +917,11 @@ class TemplateTests(SimpleTestCase): "{% endtimezone %}" "{% endtimezone %}" ) - ctx = Context({'dt': datetime.datetime(2011, 9, 1, 10, 20, 30, tzinfo=UTC), - 'tz1': ICT, 'tz2': None}) + ctx = Context({ + 'dt': datetime.datetime(2011, 9, 1, 10, 20, 30, tzinfo=UTC), + 'tz1': ICT, + 'tz2': None, + }) self.assertEqual( tpl.render(ctx), "2011-09-01T13:20:30+03:00|2011-09-01T17:20:30+07:00|2011-09-01T13:20:30+03:00" @@ -927,13 +934,17 @@ class TemplateTests(SimpleTestCase): tpl = Template("{% load tz %}{% timezone tz %}{{ dt }}{% endtimezone %}") # Use a pytz timezone as argument - ctx = Context({'dt': datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), - 'tz': pytz.timezone('Europe/Paris')}) + ctx = Context({ + 'dt': datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), + 'tz': pytz.timezone('Europe/Paris'), + }) self.assertEqual(tpl.render(ctx), "2011-09-01T12:20:30+02:00") # Use a pytz timezone name as argument - ctx = Context({'dt': datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), - 'tz': 'Europe/Paris'}) + ctx = Context({ + 'dt': datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), + 'tz': 'Europe/Paris', + }) self.assertEqual(tpl.render(ctx), "2011-09-01T12:20:30+02:00") def test_timezone_templatetag_invalid_argument(self): diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py index 0db21fe5b2..806ad23721 100644 --- a/tests/utils_tests/test_datastructures.py +++ b/tests/utils_tests/test_datastructures.py @@ -32,9 +32,7 @@ class OrderedSetTests(SimpleTestCase): class MultiValueDictTests(SimpleTestCase): def test_multivaluedict(self): - d = MultiValueDict({'name': ['Adrian', 'Simon'], - 'position': ['Developer']}) - + d = MultiValueDict({'name': ['Adrian', 'Simon'], 'position': ['Developer']}) self.assertEqual(d['name'], 'Simon') self.assertEqual(d.get('name'), 'Simon') self.assertEqual(d.getlist('name'), ['Adrian', 'Simon']) @@ -42,22 +40,17 @@ class MultiValueDictTests(SimpleTestCase): sorted(d.items()), [('name', 'Simon'), ('position', 'Developer')] ) - self.assertEqual( sorted(d.lists()), [('name', ['Adrian', 'Simon']), ('position', ['Developer'])] ) - with self.assertRaises(MultiValueDictKeyError) as cm: d.__getitem__('lastname') self.assertEqual(str(cm.exception), "'lastname'") - self.assertIsNone(d.get('lastname')) self.assertEqual(d.get('lastname', 'nonexistent'), 'nonexistent') self.assertEqual(d.getlist('lastname'), []) - self.assertEqual(d.getlist('doesnotexist', ['Adrian', 'Simon']), - ['Adrian', 'Simon']) - + self.assertEqual(d.getlist('doesnotexist', ['Adrian', 'Simon']), ['Adrian', 'Simon']) d.setlist('lastname', ['Holovaty', 'Willison']) self.assertEqual(d.getlist('lastname'), ['Holovaty', 'Willison']) self.assertEqual(sorted(d.values()), ['Developer', 'Simon', 'Willison']) diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index 533d454c69..4b90acd05c 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -728,14 +728,14 @@ class PlainTextReportTests(SimpleTestCase): class ExceptionReportTestMixin: - # Mixin used in the ExceptionReporterFilterTests and # AjaxResponseExceptionReporterFilter tests below - - breakfast_data = {'sausage-key': 'sausage-value', - 'baked-beans-key': 'baked-beans-value', - 'hash-brown-key': 'hash-brown-value', - 'bacon-key': 'bacon-value'} + breakfast_data = { + 'sausage-key': 'sausage-value', + 'baked-beans-key': 'baked-beans-value', + 'hash-brown-key': 'hash-brown-value', + 'bacon-key': 'bacon-value', + } def verify_unsafe_response(self, view, check_for_vars=True, check_for_POST_params=True): |
