Ticket #28996: bool_continue.patch

File bool_continue.patch, 31.8 KB (added by Дилян Палаузов, 7 years ago)
  • django/contrib/admin/filters.py

    diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
    a b class FieldListFilter(ListFilter):  
    152152    @classmethod
    153153    def create(cls, field, request, params, model, model_admin, field_path):
    154154        for test, list_filter_class in cls._field_list_filters:
    155             if not test(field):
    156                 continue
    157             return list_filter_class(field, request, params, model, model_admin, field_path=field_path)
     155            if test(field):
     156                return list_filter_class(field, request, params, model, model_admin, field_path=field_path)
    158157
    159158
    160159class RelatedFieldListFilter(FieldListFilter):
  • django/contrib/admin/helpers.py

    diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
    a b class InlineFieldset(Fieldset):  
    367367    def __iter__(self):
    368368        fk = getattr(self.formset, "fk", None)
    369369        for field in self.fields:
    370             if fk and fk.name == field:
    371                 continue
    372             yield Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)
     370            if not fk or fk.name != field:
     371                yield Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)
    373372
    374373
    375374class AdminErrorList(forms.utils.ErrorList):
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    a b class ModelAdmin(BaseModelAdmin):  
    831831        # Then gather them from the model admin and all parent classes,
    832832        # starting with self and working back up.
    833833        for klass in self.__class__.mro()[::-1]:
    834             class_actions = getattr(klass, 'actions', [])
    835             # Avoid trying to iterate over None
    836             if not class_actions:
    837                 continue
     834            class_actions = getattr(klass, 'actions', []) or []
    838835            actions.extend(self.get_action(action) for action in class_actions)
    839836
    840837        # get_action might have returned None, so filter any of those out.
    class ModelAdmin(BaseModelAdmin):  
    14981495        ModelForm = self.get_form(request, obj)
    14991496        if request.method == 'POST':
    15001497            form = ModelForm(request.POST, request.FILES, instance=obj)
    1501             if form.is_valid():
    1502                 form_validated = True
     1498            form_validated = form.is_valid()
     1499            if form_validated:
    15031500                new_object = self.save_form(request, form, change=not add)
    15041501            else:
    1505                 form_validated = False
    15061502                new_object = form.instance
    15071503            formsets, inline_instances = self._create_formsets(request, new_object, change=not add)
    15081504            if all_valid(formsets) and form_validated:
  • django/contrib/admin/templatetags/admin_list.py

    diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
    a b def result_headers(cl):  
    128128        order_type = ''
    129129        new_order_type = 'asc'
    130130        sort_priority = 0
    131         sorted = False
     131        sorted = i in ordering_field_columns
    132132        # Is it currently being sorted on?
    133         if i in ordering_field_columns:
    134             sorted = True
     133        if sorted:
    135134            order_type = ordering_field_columns.get(i).lower()
    136135            sort_priority = list(ordering_field_columns).index(i) + 1
    137136            th_classes.append('sorted %sending' % order_type)
  • django/contrib/admin/utils.py

    diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py
    a b def prepare_lookup_value(key, value):  
    5353    if key.endswith('__in'):
    5454        value = value.split(',')
    5555    # if key ends with __isnull, special case '' and the string literals 'false' and '0'
    56     if key.endswith('__isnull'):
    57         if value.lower() in ('', 'false', '0'):
    58             value = False
    59         else:
    60             value = True
     56    elif key.endswith('__isnull'):
     57        value = value.lower() not in ('', 'false', '0')
    6158    return value
    6259
    6360
  • django/contrib/admin/views/main.py

    diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
    a b class ChangeList:  
    378378            else:
    379379                if isinstance(field.remote_field, models.ManyToOneRel):
    380380                    # <FK>_id field names don't require a join.
    381                     if field_name == field.get_attname():
    382                         continue
    383                     return True
     381                    if field_name != field.get_attname():
     382                        return True
    384383        return False
    385384
    386385    def url_for_result(self, result):
  • django/contrib/admin/widgets.py

    diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
    a b class AutocompleteMixin:  
    438438                str(option_value) in value and
    439439                (has_selected is False or self.allow_multiple_selected)
    440440            )
    441             if selected is True and has_selected is False:
    442                 has_selected = True
     441            has_selected |= selected
    443442            index = len(default[1])
    444443            subgroup = default[1]
    445444            subgroup.append(self.create_option(name, option_value, option_label, selected_choices, index))
  • django/contrib/contenttypes/management/commands/remove_stale_contenttypes.py

    diff --git a/django/contrib/contenttypes/management/commands/remove_stale_contenttypes.py b/django/contrib/contenttypes/management/commands/remove_stale_contenttypes.py
    index 0a64a0e..e92c701 100644
    a b class Command(BaseCommand):  
    4141                        collector.collect([ct])
    4242
    4343                        for obj_type, objs in collector.data.items():
    44                             if objs == {ct}:
    45                                 continue
    46                             ct_info.append('    - %s %s object(s)' % (
    47                                 len(objs),
    48                                 obj_type._meta.label,
    49                             ))
     44                            if objs != {ct}:
     45                                ct_info.append('    - %s %s object(s)' % (
     46                                    len(objs),
     47                                    obj_type._meta.label,
     48                                ))
    5049                    content_type_display = '\n'.join(ct_info)
    5150                    self.stdout.write("""Some content types in your database are stale and can be deleted.
    5251Any objects that depend on these content types will also be deleted.
  • django/contrib/gis/gdal/geometries.py

    diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
    a b class OGRGeometry(GDALBase):  
    142142    def _from_json(geom_input):
    143143        ptr = capi.from_json(geom_input)
    144144        if GDAL_VERSION < (2, 0):
    145             has_srs = True
    146145            try:
    147146                capi.get_geom_srs(ptr)
    148147            except SRSException:
    149                 has_srs = False
    150             if not has_srs:
    151148                srs = SpatialReference(4326)
    152149                capi.assign_srs(ptr, srs.ptr)
    153150        return ptr
  • django/contrib/gis/geos/linestring.py

    diff --git a/django/contrib/gis/geos/linestring.py b/django/contrib/gis/geos/linestring.py
    a b class LineString(LinearGeometryMixin, GEOSGeometry):  
    4949                )
    5050            )
    5151
    52         if isinstance(coords, (tuple, list)):
     52        numpy_coords = not isinstance(coords, (tuple, list))
     53        if numpy_coords:
     54            shape = coords.shape  # Using numpy's shape.
     55            if len(shape) != 2:
     56                raise TypeError('Too many dimensions.')
     57            self._checkdim(shape[1])
     58            ndim = shape[1]
     59        else:
    5360            # Getting the number of coords and the number of dimensions -- which
    5461            #  must stay the same, e.g., no LineString((1, 2), (1, 2, 3)).
    5562            ndim = None
    class LineString(LinearGeometryMixin, GEOSGeometry):  
    6370                    self._checkdim(ndim)
    6471                elif len(coord) != ndim:
    6572                    raise TypeError('Dimension mismatch.')
    66             numpy_coords = False
    67         else:
    68             shape = coords.shape  # Using numpy's shape.
    69             if len(shape) != 2:
    70                 raise TypeError('Too many dimensions.')
    71             self._checkdim(shape[1])
    72             ndim = shape[1]
    73             numpy_coords = True
    7473
    7574        # Creating a coordinate sequence object because it is easier to
    7675        # set the points using its methods.
  • django/contrib/sessions/backends/file.py

    diff --git a/django/contrib/sessions/backends/file.py b/django/contrib/sessions/backends/file.py
    a b class SessionStore(SessionBase):  
    6161        modification = os.stat(self._key_to_file()).st_mtime
    6262        if settings.USE_TZ:
    6363            modification = datetime.datetime.utcfromtimestamp(modification)
    64             modification = modification.replace(tzinfo=timezone.utc)
    65         else:
    66             modification = datetime.datetime.fromtimestamp(modification)
    67         return modification
     64            return modification.replace(tzinfo=timezone.utc)
     65        return datetime.datetime.fromtimestamp(modification)
    6866
    6967    def _expiry_date(self, session_data):
    7068        """
  • django/contrib/staticfiles/storage.py

    diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
    a b class HashedFilesMixin:  
    8686        parsed_name = urlsplit(unquote(name))
    8787        clean_name = parsed_name.path.strip()
    8888        filename = (filename and urlsplit(unquote(filename)).path.strip()) or clean_name
    89         opened = False
    90         if content is None:
     89        opened = content is None
     90        if opened:
    9191            if not self.exists(filename):
    9292                raise ValueError("The file '%s' could not be found with %r." % (filename, self))
    9393            try:
    class HashedFilesMixin:  
    9595            except IOError:
    9696                # Handle directory paths and fragments
    9797                return name
    98             opened = True
    9998        try:
    10099            file_hash = self.file_hash(clean_name, content)
    101100        finally:
  • django/core/checks/templates.py

    diff --git a/django/core/checks/templates.py b/django/core/checks/templates.py
    a b E002 = Error(  
    1717
    1818@register(Tags.templates)
    1919def check_setting_app_dirs_loaders(app_configs, **kwargs):
    20     passed_check = True
    21     for conf in settings.TEMPLATES:
    22         if not conf.get('APP_DIRS'):
    23             continue
    24         if 'loaders' in conf.get('OPTIONS', {}):
    25             passed_check = False
    26     return [] if passed_check else [E001]
     20    return [E001] if any(conf.get('APP_DIRS') and
     21                         'loaders' in conf.get('OPTIONS', {}) for conf in settings.TEMPLATES) else []
    2722
    2823
    2924@register(Tags.templates)
  • django/core/files/uploadhandler.py

    diff --git a/django/core/files/uploadhandler.py b/django/core/files/uploadhandler.py
    a b class MemoryFileUploadHandler(FileUploadHandler):  
    160160        """
    161161        # Check the content-length header to see if we should
    162162        # If the post is too large, we cannot use the Memory handler.
    163         if content_length > settings.FILE_UPLOAD_MAX_MEMORY_SIZE:
    164             self.activated = False
    165         else:
    166             self.activated = True
     163        self.activated = content_length <= settings.FILE_UPLOAD_MAX_MEMORY_SIZE
    167164
    168165    def new_file(self, *args, **kwargs):
    169166        super().new_file(*args, **kwargs)
  • django/core/mail/message.py

    diff --git a/django/core/mail/message.py b/django/core/mail/message.py
    a b class EmailMessage:  
    271271            # Use cached DNS_NAME for performance
    272272            msg['Message-ID'] = make_msgid(domain=DNS_NAME)
    273273        for name, value in self.extra_headers.items():
    274             if name.lower() == 'from':  # From is already handled
    275                 continue
    276             msg[name] = value
     274            if name.lower() != 'from':  # From is already handled
     275                msg[name] = value
    277276        return msg
    278277
    279278    def recipients(self):
  • django/core/signing.py

    diff --git a/django/core/signing.py b/django/core/signing.py
    a b def loads(s, key=None, salt='django.core.signing', serializer=JSONSerializer, ma  
    132132    # TimestampSigner.unsign() returns str but base64 and zlib compression
    133133    # operate on bytes.
    134134    base64d = force_bytes(TimestampSigner(key, salt=salt).unsign(s, max_age=max_age))
    135     decompress = False
    136     if base64d[:1] == b'.':
     135    decompress = base64d[:1] == b'.'
     136    if decompress:
    137137        # It's compressed; uncompress it first
    138138        base64d = base64d[1:]
    139         decompress = True
    140139    data = b64_decode(base64d)
    141140    if decompress:
    142141        data = zlib.decompress(data)
  • django/db/backends/base/schema.py

    diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
    a b class BaseDatabaseSchemaEditor:  
    570570            # db_index=True.
    571571            index_names = self._constraint_names(model, [old_field.column], index=True, type_=Index.suffix)
    572572            for index_name in index_names:
    573                 if index_name in meta_index_names:
     573                if index_name not in meta_index_names:
    574574                    # The only way to check if an index was created with
    575575                    # db_index=True or with Index(['field'], name='foo')
    576576                    # is to look at its name (refs #28053).
    577                     continue
    578                 self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_name))
     577                    self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_name))
    579578        # Change check constraints?
    580579        if old_db_params['check'] != new_db_params['check'] and old_db_params['check']:
    581580            constraint_names = self._constraint_names(model, [old_field.column], check=True)
  • django/db/migrations/autodetector.py

    diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
    a b class MigrationAutodetector:  
    261261                    deps_satisfied = True
    262262                    operation_dependencies = set()
    263263                    for dep in operation._auto_deps:
    264                         is_swappable_dep = False
    265                         if dep[0] == "__setting__":
     264                        is_swappable_dep = dep[0] == "__setting__"
     265                        if is_swappable_dep:
    266266                            # We need to temporarily resolve the swappable dependency to prevent
    267267                            # circular references. While keeping the dependency checks on the
    268268                            # resolved model we still add the swappable dependencies.
    class MigrationAutodetector:  
    270270                            resolved_app_label, resolved_object_name = getattr(settings, dep[1]).split('.')
    271271                            original_dep = dep
    272272                            dep = (resolved_app_label, resolved_object_name.lower(), dep[2], dep[3])
    273                             is_swappable_dep = True
    274273                        if dep[0] != app_label and dep[0] != "__setting__":
    275274                            # External app dependency. See if it's not yet
    276275                            # satisfied.
    class MigrationAutodetector:  
    831830            dependencies.extend(self._get_dependencies_for_foreign_key(field))
    832831        # You can't just add NOT NULL fields with no default or fields
    833832        # which don't allow empty strings as default.
    834         preserve_default = True
    835833        time_fields = (models.DateField, models.DateTimeField, models.TimeField)
    836         if (not field.null and not field.has_default() and
    837                 not field.many_to_many and
    838                 not (field.blank and field.empty_strings_allowed) and
    839                 not (isinstance(field, time_fields) and field.auto_now)):
     834        preserve_default = (field.null or field.has_default() or field.many_to_many or
     835                            (field.blank and field.empty_strings_allowed) or
     836                            (isinstance(field, time_fields) and field.auto_now))
     837        if not preserve_default:
    840838            field = field.clone()
    841839            if isinstance(field, time_fields) and field.auto_now_add:
    842840                field.default = self.questioner.ask_auto_now_add_addition(field_name, model_name)
    843841            else:
    844842                field.default = self.questioner.ask_not_null_addition(field_name, model_name)
    845             preserve_default = False
    846843        self.add_operation(
    847844            app_label,
    848845            operations.AddField(
  • django/db/migrations/graph.py

    diff --git a/django/db/migrations/graph.py b/django/db/migrations/graph.py
    a b class MigrationGraph:  
    367367        plan = []
    368368        for node in nodes:
    369369            for migration in self.forwards_plan(node):
    370                 if migration not in plan:
    371                     if not at_end and migration in nodes:
    372                         continue
     370                if migration in plan or at_end or migration not in nodes:
    373371                    plan.append(migration)
    374372        project_state = ProjectState(real_apps=real_apps)
    375373        for node in plan:
  • django/db/migrations/loader.py

    diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py
    a b class MigrationLoader:  
    172172        dependencies find the correct root node.
    173173        """
    174174        for parent in migration.dependencies:
    175             if parent[0] != key[0] or parent[1] == '__first__':
     175            if parent[0] == key[0] and parent[1] != '__first__':
    176176                # Ignore __first__ references to the same app (#22325).
    177                 continue
    178             self.graph.add_dependency(migration, key, parent, skip_validation=True)
     177                self.graph.add_dependency(migration, key, parent, skip_validation=True)
    179178
    180179    def add_external_dependencies(self, key, migration):
    181180        for parent in migration.dependencies:
  • django/db/models/fields/related.py

    diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
    a b class RelatedField(FieldCacheMixin, Field):  
    109109        related_name = self.remote_field.related_name
    110110        if related_name is None:
    111111            return []
    112         is_valid_id = True
    113         if keyword.iskeyword(related_name):
    114             is_valid_id = False
    115         if not related_name.isidentifier():
    116             is_valid_id = False
     112        is_valid_id = not keyword.iskeyword(related_name) and related_name.isidentifier()
    117113        if not (is_valid_id or related_name.endswith('+')):
    118114            return [
    119115                checks.Error(
  • django/db/models/options.py

    diff --git a/django/db/models/options.py b/django/db/models/options.py
    a b class Options:  
    753753
    754754        # We must keep track of which models we have already seen. Otherwise we
    755755        # could include the same field multiple times from different models.
    756         topmost_call = False
    757         if seen_models is None:
     756        topmost_call = seen_models is None
     757        if topmost_call:
    758758            seen_models = set()
    759             topmost_call = True
    760759        seen_models.add(self.model)
    761760
    762761        # Creates a cache key composed of all arguments
    class Options:  
    785784                for obj in parent._meta._get_fields(
    786785                        forward=forward, reverse=reverse, include_parents=include_parents,
    787786                        include_hidden=include_hidden, seen_models=seen_models):
    788                     if getattr(obj, 'parent_link', False) and obj.model != self.concrete_model:
    789                         continue
    790                     fields.append(obj)
     787                    if not getattr(obj, 'parent_link', False) or obj.model == self.concrete_model:
     788                        fields.append(obj)
    791789        if reverse and not self.proxy:
    792790            # Tree is computed once and cached until the app cache is expired.
    793791            # It is composed of a list of fields pointing to the current model
  • django/db/models/sql/compiler.py

    diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
    a b class SQLCompiler:  
    114114            for col in cols:
    115115                expressions.append(col)
    116116        for expr, (sql, params, is_ref) in order_by:
    117             if expr.contains_aggregate:
    118                 continue
    119             # We can skip References to select clause, as all expressions in
    120             # the select clause are already part of the group by.
    121             if is_ref:
    122                 continue
    123             expressions.extend(expr.get_source_expressions())
     117            if not expr.contains_aggregate and not is_ref:
     118                # We can skip References to select clause, as all expressions in
     119                # the select clause are already part of the group by.
     120                expressions.extend(expr.get_source_expressions())
    124121        having_group_by = self.having.get_group_by_cols() if self.having else ()
    125122        for expr in having_group_by:
    126123            expressions.append(expr)
    class SQLCompiler:  
    283280                continue
    284281
    285282            col, order = get_order_dir(field, asc)
    286             descending = True if order == 'DESC' else False
     283            descending = order == 'DESC'
    287284
    288285            if col in self.query.annotation_select:
    289286                # Reference to expression in SELECT clause
    class SQLCompiler:  
    646643        The 'name' is of the form 'field1__field2__...__fieldN'.
    647644        """
    648645        name, order = get_order_dir(name, default_order)
    649         descending = True if order == 'DESC' else False
     646        descending = order == 'DESC'
    650647        pieces = name.split(LOOKUP_SEP)
    651648        field, targets, alias, joins, path, opts = self._setup_joins(pieces, opts, alias)
    652649
    class SQLCompiler:  
    747744        # included in the related selection.
    748745        fields_found = set()
    749746        if requested is None:
    750             if isinstance(self.query.select_related, dict):
     747            restricted = isinstance(self.query.select_related, dict)
     748            if restricted:
    751749                requested = self.query.select_related
    752                 restricted = True
    753             else:
    754                 restricted = False
    755750
    756751        def get_related_klass_infos(klass_info, related_klass_infos):
    757752            klass_info['related_klass_infos'] = related_klass_infos
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    a b class Query:  
    666666            workset = {}
    667667            for model, values in seen.items():
    668668                for field in model._meta.local_fields:
    669                     if field in values:
    670                         continue
    671                     m = field.model._meta.concrete_model
    672                     add_to_dict(workset, m, field)
     669                    if field not in values:
     670                        m = field.model._meta.concrete_model
     671                        add_to_dict(workset, m, field)
    673672            for model, values in must_include.items():
    674673                # If we haven't included a model in workset, we don't add the
    675674                # corresponding must_include fields for that model, since an
  • django/forms/formsets.py

    diff --git a/django/forms/formsets.py b/django/forms/formsets.py
    a b def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,  
    437437
    438438def all_valid(formsets):
    439439    """Return True if every formset in formsets is valid."""
    440     valid = True
    441     for formset in formsets:
    442         if not formset.is_valid():
    443             valid = False
    444     return valid
     440    return all(formset.is_valid() for formset in formsets)
  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    a b class BaseModelFormSet(BaseFormSet):  
    587587        return field.to_python
    588588
    589589    def _construct_form(self, i, **kwargs):
    590         pk_required = False
    591         if i < self.initial_form_count():
    592             pk_required = True
     590        pk_required = i < self.initial_form_count()
     591        if pk_required:
    593592            if self.is_bound:
    594593                pk_key = '%s-%s' % (self.add_prefix(i), self.model._meta.pk.name)
    595594                try:
  • django/forms/widgets.py

    diff --git a/django/forms/widgets.py b/django/forms/widgets.py
    a b class ChoiceWidget(Widget):  
    599599                    str(subvalue) in value and
    600600                    (not has_selected or self.allow_multiple_selected)
    601601                )
    602                 if selected and not has_selected:
    603                     has_selected = True
     602                has_selected |= selected
    604603                subgroup.append(self.create_option(
    605604                    name, subvalue, sublabel, selected, index,
    606605                    subindex=subindex, attrs=attrs,
  • django/utils/cache.py

    diff --git a/django/utils/cache.py b/django/utils/cache.py
    a b def learn_cache_key(request, response, cache_timeout=None, key_prefix=None, cach  
    376376        headerlist = []
    377377        for header in cc_delim_re.split(response['Vary']):
    378378            header = header.upper().replace('-', '_')
    379             if header == 'ACCEPT_LANGUAGE' and is_accept_language_redundant:
    380                 continue
    381             headerlist.append('HTTP_' + header)
     379            if header != 'ACCEPT_LANGUAGE' or not is_accept_language_redundant:
     380                headerlist.append('HTTP_' + header)
    382381        headerlist.sort()
    383382        cache.set(cache_key, headerlist, cache_timeout)
    384383        return _generate_cache_key(request, request.method, headerlist, key_prefix)
  • django/utils/datastructures.py

    diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
    a b class DictWrapper(dict):  
    275275        present). If the prefix is present, pass the value through self.func
    276276        before returning, otherwise return the raw value.
    277277        """
    278         if key.startswith(self.prefix):
    279             use_func = True
     278        use_func = key.startswith(self.prefix)
     279        if use_func:
    280280            key = key[len(self.prefix):]
    281         else:
    282             use_func = False
    283281        value = super().__getitem__(key)
    284282        if use_func:
    285283            return self.func(value)
  • django/utils/regex_helper.py

    diff --git a/django/utils/regex_helper.py b/django/utils/regex_helper.py
    a b def normalize(pattern):  
    176176
    177177            if consume_next:
    178178                ch, escaped = next(pattern_iter)
    179             else:
    180                 consume_next = True
     179            consume_next = True
    181180    except StopIteration:
    182181        pass
    183182    except NotImplementedError:
  • docs/ref/contrib/admin/index.txt

    diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
    a b templates used by the :class:`ModelAdmin` views:  
    16941694            def get_formsets_with_inlines(self, request, obj=None):
    16951695                for inline in self.get_inline_instances(request, obj):
    16961696                    # hide MyInline in the add view
    1697                     if isinstance(inline, MyInline) and obj is None:
    1698                         continue
    1699                     yield inline.get_formset(request, obj), inline
     1697                    if not isinstance(inline, MyInline) or obj is not None:
     1698                        yield inline.get_formset(request, obj), inline
    17001699
    17011700.. method:: ModelAdmin.formfield_for_foreignkey(db_field, request, **kwargs)
    17021701
  • tests/gis_tests/distapp/tests.py

    diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
    a b class DistanceTest(TestCase):  
    8181        # Now performing the `dwithin` queries on a geodetic coordinate system.
    8282        for dist in au_dists:
    8383            with self.subTest(dist=dist):
    84                 if isinstance(dist, D) and not oracle:
    85                     type_error = True
    86                 else:
    87                     type_error = False
     84                type_error = isinstance(dist, D) and not oracle
    8885
    8986                if isinstance(dist, tuple):
    9087                    if oracle or spatialite:
  • tests/invalid_models_tests/test_models.py

    diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
    a b def get_max_column_name_length():  
    1717    for db in settings.DATABASES:
    1818        connection = connections[db]
    1919        max_name_length = connection.ops.max_name_length()
    20         if max_name_length is None or connection.features.truncates_names:
    21             continue
    22         else:
    23             if allowed_len is None:
    24                 allowed_len = max_name_length
    25                 db_alias = db
    26             elif max_name_length < allowed_len:
     20        if max_name_length is not None and not connection.features.truncates_names:
     21            if allowed_len is None or max_name_length < allowed_len:
    2722                allowed_len = max_name_length
    2823                db_alias = db
    2924
  • tests/messages_tests/base.py

    diff --git a/tests/messages_tests/base.py b/tests/messages_tests/base.py
    a b class BaseTests:  
    252252    def test_middleware_disabled_fail_silently(self):
    253253        """
    254254        When the middleware is disabled, an exception is not raised
    255         if 'fail_silently' = True
     255        if 'fail_silently' == True
    256256        """
    257257        data = {
    258258            'messages': ['Test message %d' % x for x in range(5)],
  • tests/runtests.py

    diff --git a/tests/runtests.py b/tests/runtests.py
    a b def get_test_modules():  
    8585
    8686    for modpath, dirpath in discovery_paths:
    8787        for f in os.listdir(dirpath):
    88             if ('.' in f or
    89                     os.path.basename(f) in SUBDIRS_TO_SKIP or
    90                     os.path.isfile(f) or
    91                     not os.path.exists(os.path.join(dirpath, f, '__init__.py'))):
    92                 continue
    93             modules.append((modpath, f))
     88            if ('.' not in f and
     89                    os.path.basename(f) not in SUBDIRS_TO_SKIP and
     90                    not os.path.isfile(f) and
     91                    os.path.exists(os.path.join(dirpath, f, '__init__.py'))):
     92                modules.append((modpath, f))
    9493    return modules
    9594
    9695
    def setup(verbosity, test_labels, parallel):  
    189188        # if the module (or an ancestor) was named on the command line, or
    190189        # no modules were named (i.e., run all), import
    191190        # this module and add it to INSTALLED_APPS.
    192         if not test_labels:
    193             module_found_in_labels = True
    194         else:
    195             module_found_in_labels = any(
    196                 # exact match or ancestor match
    197                 module_label == label or module_label.startswith(label + '.')
    198                 for label in test_labels_set)
     191        module_found_in_labels = not test_labels or any(
     192            # exact match or ancestor match
     193            module_label == label or module_label.startswith(label + '.')
     194            for label in test_labels_set)
    199195
    200196        if module_name in CONTRIB_TESTS_TO_APPS and module_found_in_labels:
    201197            settings.INSTALLED_APPS.append(CONTRIB_TESTS_TO_APPS[module_name])
Back to Top