Ticket #30153: test.patch

File test.patch, 2.4 KB (added by Matthias Kestenholz, 6 years ago)

Test showing the problem

  • tests/admin_inlines/models.py

    diff --git a/tests/admin_inlines/models.py b/tests/admin_inlines/models.py
    index cb1ec39ae5..d7c3b324a3 100644
    a b Testing of admin inline formsets.  
    33"""
    44import random
    55
     6from django import forms
    67from django.contrib.contenttypes.fields import GenericForeignKey
    78from django.contrib.contenttypes.models import ContentType
    89from django.db import models
    class Inner2(models.Model):  
    8889    holder = models.ForeignKey(Holder2, models.CASCADE)
    8990
    9091
     92class CustomNumberInput(forms.NumberInput):
     93    class Media:
     94        js = ("custom_number.js",)
     95
     96
     97class CustomIntegerField(models.IntegerField):
     98    def formfield(self, **kwargs):
     99        kwargs["widget"] = CustomNumberInput
     100        return super().formfield(**kwargs)
     101
     102
    91103class Holder3(models.Model):
    92     dummy = models.IntegerField()
     104    # The ordering of those two fields is important.
     105    # https://code.djangoproject.com/ticket/30153
     106    dummy = CustomIntegerField()
     107    date = models.DateField(blank=True, null=True)
    93108
    94109
    95110class Inner3(models.Model):
    96     dummy = models.IntegerField()
     111    dummy = CustomIntegerField()
    97112    holder = models.ForeignKey(Holder3, models.CASCADE)
    98113
    99114# Models for ticket #8190
  • tests/admin_inlines/tests.py

    diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py
    index 749b3dd75f..a4c35da252 100644
    a b class TestInlineMedia(TestDataMixin, TestCase):  
    490490        )
    491491        self.assertContains(response, 'my_awesome_inline_scripts.js')
    492492
     493        self.assertEqual(
     494            response.context["media"]._js,
     495            [
     496                'admin/js/vendor/jquery/jquery.min.js',
     497                'admin/js/jquery.init.js',
     498                'admin/js/core.js',
     499                'admin/js/admin/RelatedObjectLookups.js',
     500                'admin/js/actions.min.js',
     501                'admin/js/urlify.js',
     502                'admin/js/prepopulate.min.js',
     503                'admin/js/vendor/xregexp/xregexp.min.js',
     504                'admin/js/calendar.js',
     505                'admin/js/admin/DateTimeShortcuts.js',
     506                'admin/js/inlines.min.js',
     507                'my_awesome_inline_scripts.js',
     508                'custom_number.js',
     509            ],
     510        )
     511
    493512    def test_all_inline_media(self):
    494513        holder = Holder2(dummy=13)
    495514        holder.save()
Back to Top