diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py
|
a
|
b
|
class Command(BaseCommand):
|
| 264 | 264 | to the given database table name. |
| 265 | 265 | """ |
| 266 | 266 | unique_together = [] |
| 267 | | for index, params in constraints.items(): |
| | 267 | for params in constraints.values(): |
| 268 | 268 | if params['unique']: |
| 269 | 269 | columns = params['columns'] |
| 270 | 270 | if len(columns) > 1: |
diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
|
a
|
b
|
class WSGIRequestHandler(simple_server.WSGIRequestHandler):
|
| 128 | 128 | # the WSGI environ. This prevents header-spoofing based on ambiguity |
| 129 | 129 | # between underscores and dashes both normalized to underscores in WSGI |
| 130 | 130 | # env vars. Nginx and Apache 2.4+ both do this as well. |
| 131 | | for k, v in self.headers.items(): |
| | 131 | for k in self.headers.keys(): |
| 132 | 132 | if '_' in k: |
| 133 | 133 | del self.headers[k] |
| 134 | 134 | |
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
|
a
|
b
|
class MigrationAutodetector:
|
| 348 | 348 | m2.dependencies.append((app_label, m1.name)) |
| 349 | 349 | |
| 350 | 350 | # De-dupe dependencies |
| 351 | | for app_label, migrations in self.migrations.items(): |
| | 351 | for migrations in self.migrations.values(): |
| 352 | 352 | for migration in migrations: |
| 353 | 353 | migration.dependencies = list(set(migration.dependencies)) |
| 354 | 354 | |
| … |
… |
class MigrationAutodetector:
|
| 588 | 588 | # Generate other opns |
| 589 | 589 | related_dependencies = [ |
| 590 | 590 | (app_label, model_name, name, True) |
| 591 | | for name, field in sorted(related_fields.items()) |
| | 591 | for name in sorted(related_fields.keys()) |
| 592 | 592 | ] |
| 593 | 593 | related_dependencies.append((app_label, model_name, None, True)) |
| 594 | 594 | for index in indexes: |
| … |
… |
class MigrationAutodetector:
|
| 736 | 736 | ) |
| 737 | 737 | ) |
| 738 | 738 | # Then remove each related field |
| 739 | | for name, field in sorted(related_fields.items()): |
| | 739 | for name in sorted(related_fields.keys()): |
| 740 | 740 | self.add_operation( |
| 741 | 741 | app_label, |
| 742 | 742 | operations.RemoveField( |
| … |
… |
class MigrationAutodetector:
|
| 757 | 757 | if not related_object.many_to_many: |
| 758 | 758 | dependencies.append((related_object_app_label, object_name, field_name, "alter")) |
| 759 | 759 | |
| 760 | | for name, field in sorted(related_fields.items()): |
| | 760 | for name in sorted(related_fields.keys()): |
| 761 | 761 | dependencies.append((app_label, model_name, name, False)) |
| 762 | 762 | # We're referenced in another field's through= |
| 763 | 763 | through_user = self.through_users.get((app_label, model_state.name_lower)) |
| … |
… |
class MigrationAutodetector:
|
| 1171 | 1171 | next_number += 1 |
| 1172 | 1172 | migration.name = new_name |
| 1173 | 1173 | # Now fix dependencies |
| 1174 | | for app_label, migrations in changes.items(): |
| | 1174 | for migrations in changes.values(): |
| 1175 | 1175 | for migration in migrations: |
| 1176 | 1176 | migration.dependencies = [name_map.get(d, d) for d in migration.dependencies] |
| 1177 | 1177 | return changes |
diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
|
a
|
b
|
class Collector:
|
| 308 | 308 | ) |
| 309 | 309 | |
| 310 | 310 | # update collected instances |
| 311 | | for model, instances_for_fieldvalues in self.field_updates.items(): |
| | 311 | for instances_for_fieldvalues in self.field_updates.values(): |
| 312 | 312 | for (field, value), instances in instances_for_fieldvalues.items(): |
| 313 | 313 | for obj in instances: |
| 314 | 314 | setattr(obj, field.attname, value) |
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
|
a
|
b
|
class Query:
|
| 1749 | 1749 | """ |
| 1750 | 1750 | group_by = list(self.select) |
| 1751 | 1751 | if self.annotation_select: |
| 1752 | | for alias, annotation in self.annotation_select.items(): |
| | 1752 | for annotation in self.annotation_select.values(): |
| 1753 | 1753 | for col in annotation.get_group_by_cols(): |
| 1754 | 1754 | group_by.append(col) |
| 1755 | 1755 | self.group_by = tuple(group_by) |
diff --git a/django/test/utils.py b/django/test/utils.py
|
a
|
b
|
def setup_databases(verbosity, interactive, keepdb=False, debug_sql=False, paral
|
| 159 | 159 | |
| 160 | 160 | old_names = [] |
| 161 | 161 | |
| 162 | | for signature, (db_name, aliases) in test_databases.items(): |
| | 162 | for (db_name, aliases) in test_databases.values(): |
| 163 | 163 | first_alias = None |
| 164 | 164 | for alias in aliases: |
| 165 | 165 | connection = connections[alias] |
diff --git a/django/views/debug.py b/django/views/debug.py
|
a
|
b
|
class SafeExceptionReporterFilter(ExceptionReporterFilter):
|
| 164 | 164 | cleansed = request.POST.copy() |
| 165 | 165 | if sensitive_post_parameters == '__ALL__': |
| 166 | 166 | # Cleanse all parameters. |
| 167 | | for k, v in cleansed.items(): |
| | 167 | for k in cleansed.keys(): |
| 168 | 168 | cleansed[k] = CLEANSED_SUBSTITUTE |
| 169 | 169 | return cleansed |
| 170 | 170 | else: |
| … |
… |
class SafeExceptionReporterFilter(ExceptionReporterFilter):
|
| 213 | 213 | if self.is_active(request) and sensitive_variables: |
| 214 | 214 | if sensitive_variables == '__ALL__': |
| 215 | 215 | # Cleanse all variables |
| 216 | | for name, value in tb_frame.f_locals.items(): |
| | 216 | for name in tb_frame.f_locals.keys(): |
| 217 | 217 | cleansed[name] = CLEANSED_SUBSTITUTE |
| 218 | 218 | else: |
| 219 | 219 | # Cleanse specified variables |
| 220 | | for name, value in tb_frame.f_locals.items(): |
| | 220 | for name in tb_frame.f_locals.keys(): |
| 221 | 221 | if name in sensitive_variables: |
| 222 | 222 | value = CLEANSED_SUBSTITUTE |
| 223 | 223 | else: |
diff --git a/tests/backends/postgresql/test_creation.py b/tests/backends/postgresql/test_creation.py
|
a
|
b
|
class DatabaseCreationTests(SimpleTestCase):
|
| 33 | 33 | try: |
| 34 | 34 | yield |
| 35 | 35 | finally: |
| 36 | | for name, value in kwargs.items(): |
| | 36 | for name in kwargs.keys(): |
| 37 | 37 | if name in saved_values: |
| 38 | 38 | settings[name] = saved_values[name] |
| 39 | 39 | else: |
diff --git a/tests/backends/postgresql/test_server_side_cursors.py b/tests/backends/postgresql/test_server_side_cursors.py
|
a
|
b
|
class ServerSideCursorsPostgres(TestCase):
|
| 27 | 27 | |
| 28 | 28 | @contextmanager |
| 29 | 29 | def override_db_setting(self, **kwargs): |
| 30 | | for setting, value in kwargs.items(): |
| | 30 | for setting in kwargs.keys(): |
| 31 | 31 | original_value = connection.settings_dict.get(setting) |
| 32 | 32 | if setting in connection.settings_dict: |
| 33 | 33 | self.addCleanup(operator.setitem, connection.settings_dict, setting, original_value) |
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
|
a
|
b
|
class IntrospectionTests(TransactionTestCase):
|
| 176 | 176 | constraints = connection.introspection.get_constraints(cursor, Article._meta.db_table) |
| 177 | 177 | index = {} |
| 178 | 178 | index2 = {} |
| 179 | | for key, val in constraints.items(): |
| | 179 | for val in constraints.values(): |
| 180 | 180 | if val['columns'] == ['headline', 'pub_date']: |
| 181 | 181 | index = val |
| 182 | 182 | if val['columns'] == ['headline', 'response_to_id', 'pub_date', 'reporter_id']: |
| … |
… |
class IntrospectionTests(TransactionTestCase):
|
| 198 | 198 | ['response_to_id'], |
| 199 | 199 | ['headline', 'response_to_id', 'pub_date', 'reporter_id'], |
| 200 | 200 | ] |
| 201 | | for key, val in constraints.items(): |
| | 201 | for val in constraints.values(): |
| 202 | 202 | if val['index'] and not (val['primary_key'] or val['unique']): |
| 203 | 203 | self.assertIn(val['columns'], expected_columns) |
| 204 | 204 | self.assertEqual(val['orders'], ['ASC'] * len(val['columns'])) |
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
|
a
|
b
|
class SchemaTests(TransactionTestCase):
|
| 180 | 180 | """ |
| 181 | 181 | constraints = self.get_constraints(model._meta.db_table) |
| 182 | 182 | constraint_fk = None |
| 183 | | for name, details in constraints.items(): |
| | 183 | for details in constraints.values(): |
| 184 | 184 | if details['columns'] == [column] and details['foreign_key']: |
| 185 | 185 | constraint_fk = details['foreign_key'] |
| 186 | 186 | break |
| … |
… |
class SchemaTests(TransactionTestCase):
|
| 836 | 836 | editor.create_model(LocalBook) |
| 837 | 837 | # Ensure no FK constraint exists |
| 838 | 838 | constraints = self.get_constraints(LocalBook._meta.db_table) |
| 839 | | for name, details in constraints.items(): |
| | 839 | for details in constraints.values(): |
| 840 | 840 | if details['foreign_key']: |
| 841 | 841 | self.fail('Found an unexpected FK constraint to %s' % details['columns']) |
| 842 | 842 | old_field = LocalBook._meta.get_field("author") |
| … |
… |
class SchemaTests(TransactionTestCase):
|
| 1430 | 1430 | editor.create_model(Author) |
| 1431 | 1431 | # Ensure the constraint exists |
| 1432 | 1432 | constraints = self.get_constraints(Author._meta.db_table) |
| 1433 | | for name, details in constraints.items(): |
| | 1433 | for details in constraints.values(): |
| 1434 | 1434 | if details['columns'] == ["height"] and details['check']: |
| 1435 | 1435 | break |
| 1436 | 1436 | else: |
| … |
… |
class SchemaTests(TransactionTestCase):
|
| 1442 | 1442 | with connection.schema_editor() as editor: |
| 1443 | 1443 | editor.alter_field(Author, old_field, new_field, strict=True) |
| 1444 | 1444 | constraints = self.get_constraints(Author._meta.db_table) |
| 1445 | | for name, details in constraints.items(): |
| | 1445 | for details in constraints.values(): |
| 1446 | 1446 | if details['columns'] == ["height"] and details['check']: |
| 1447 | 1447 | self.fail("Check constraint for height found") |
| 1448 | 1448 | # Alter the column to re-add it |
| … |
… |
class SchemaTests(TransactionTestCase):
|
| 1450 | 1450 | with connection.schema_editor() as editor: |
| 1451 | 1451 | editor.alter_field(Author, new_field, new_field2, strict=True) |
| 1452 | 1452 | constraints = self.get_constraints(Author._meta.db_table) |
| 1453 | | for name, details in constraints.items(): |
| | 1453 | for details in constraints.values(): |
| 1454 | 1454 | if details['columns'] == ["height"] and details['check']: |
| 1455 | 1455 | break |
| 1456 | 1456 | else: |
diff --git a/tests/serializers/test_data.py b/tests/serializers/test_data.py
|
a
|
b
|
def inherited_create(pk, klass, data):
|
| 106 | 106 | # automatically is easier than manually creating both. |
| 107 | 107 | models.Model.save(instance) |
| 108 | 108 | created = [instance] |
| 109 | | for klass, field in instance._meta.parents.items(): |
| | 109 | for klass in instance._meta.parents.keys(): |
| 110 | 110 | created.append(klass.objects.get(id=pk)) |
| 111 | 111 | return created |
| 112 | 112 | |
diff --git a/tests/validation/test_unique.py b/tests/validation/test_unique.py
|
a
|
b
|
class GetUniqueCheckTests(unittest.TestCase):
|
| 47 | 47 | (('foo', 'bar'), ('bar', 'baz'))), |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | | for test_name, (unique_together, normalized) in data.items(): |
| | 50 | for (unique_together, normalized) in data.values(): |
| 51 | 51 | class M(models.Model): |
| 52 | 52 | foo = models.IntegerField() |
| 53 | 53 | bar = models.IntegerField() |
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
|
a
|
b
|
class ExceptionReportTestMixin:
|
| 769 | 769 | self.assertContains(response, 'sauce', status_code=500) |
| 770 | 770 | self.assertNotContains(response, 'worcestershire', status_code=500) |
| 771 | 771 | if check_for_POST_params: |
| 772 | | for k, v in self.breakfast_data.items(): |
| | 772 | for k in self.breakfast_data.keys(): |
| 773 | 773 | # All POST parameters' names are shown. |
| 774 | 774 | self.assertContains(response, k, status_code=500) |
| 775 | 775 | # Non-sensitive POST parameters' values are shown. |
| … |
… |
class ExceptionReportTestMixin:
|
| 858 | 858 | self.assertNotIn('worcestershire', body_html) |
| 859 | 859 | |
| 860 | 860 | if check_for_POST_params: |
| 861 | | for k, v in self.breakfast_data.items(): |
| | 861 | for k in self.breakfast_data.keys(): |
| 862 | 862 | # All POST parameters' names are shown. |
| 863 | 863 | self.assertIn(k, body_plain) |
| 864 | 864 | # Non-sensitive POST parameters' values are shown. |