[Python-modules-commits] r30675 - in packages/django-polymorphic/trunk/debian (3 files)

fladi-guest at users.alioth.debian.org fladi-guest at users.alioth.debian.org
Fri Sep 19 20:16:36 UTC 2014


    Date: Friday, September 19, 2014 @ 20:16:35
  Author: fladi-guest
Revision: 30675

 Add django-1.7.patch to fix the test-suite with Django 1.7 (Closes: #755602).

Added:
  packages/django-polymorphic/trunk/debian/patches/
  packages/django-polymorphic/trunk/debian/patches/django-1.7.patch
  packages/django-polymorphic/trunk/debian/patches/series

Added: packages/django-polymorphic/trunk/debian/patches/django-1.7.patch
===================================================================
--- packages/django-polymorphic/trunk/debian/patches/django-1.7.patch	                        (rev 0)
+++ packages/django-polymorphic/trunk/debian/patches/django-1.7.patch	2014-09-19 20:16:35 UTC (rev 30675)
@@ -0,0 +1,334 @@
+Description: Fix tests for Django-1.7
+ Taken from upstream to fix the testsuite for Django 1.7.
+Author: Chad Shryock <cdshryock at gannett.com>
+Last-Update: 2014-09-19
+Origin: https://github.com/chrisglass/django_polymorphic/pull/102
+Bug: https://bugs.debian.org/755602
+
+--- a/polymorphic/admin.py
++++ b/polymorphic/admin.py
+@@ -220,8 +220,17 @@
+ 
+ 
+     def queryset(self, request):
++        return self.get_queryset(request)
++
++
++    def get_queryset(self, request):
+         # optimize the list display.
+-        qs = super(PolymorphicParentModelAdmin, self).queryset(request)
++        parent_self = super(PolymorphicParentModelAdmin, self)
++        if hasattr(parent_self, 'get_queryset'):
++            qs = parent_self.get_queryset(request)
++        else:
++            qs = parent_self.queryset(request)
++
+         if not self.polymorphic_list:
+             qs = qs.non_polymorphic()
+         return qs
+@@ -262,7 +271,8 @@
+         Expose the custom URLs for the subclasses and the URL resolver.
+         """
+         urls = super(PolymorphicParentModelAdmin, self).get_urls()
+-        info = self.model._meta.app_label, self.model._meta.module_name
++        meta = self.model._meta
++        info = meta.app_label, getattr(meta, 'model_name', meta.module_name)
+ 
+         # Patch the change URL so it's not a big catch-all; allowing all custom URLs to be added to the end.
+         # The url needs to be recreated, patching url.regex is not an option Django 1.4's LocaleRegexProvider changed it.
+--- a/polymorphic/manager.py
++++ b/polymorphic/manager.py
+@@ -30,9 +30,13 @@
+ 
+         super(PolymorphicManager, self).__init__(*args, **kwrags)
+ 
+-    def get_query_set(self):
++    def get_queryset(self):
+         return self.queryset_class(self.model, using=self._db)
+ 
++    def get_query_set(self):
++        return self.get_queryset()
++
++
+     # Proxy all unknown method calls to the queryset, so that its members are
+     # directly accessible as PolymorphicModel.objects.*
+     # The advantage of this method is that not yet known member functions of derived querysets will be proxied as well.
+--- a/runtests.py
++++ b/runtests.py
+@@ -18,6 +18,10 @@
+ # Detect location and available modules
+ module_root = dirname(realpath(__file__))
+ 
++test_runner = 'django.test.runner.DiscoverRunner'
++if django.VERSION[:2] < (1, 6):
++    test_runner = 'django.test.simple.DjangoTestSuiteRunner'
++
+ # Inline settings file
+ settings.configure(
+     DEBUG = False,  # will be False anyway by DjangoTestRunner.
+@@ -43,9 +47,15 @@
+         'polymorphic',
+     ),
+     SITE_ID = 3,
++    TEST_RUNNER = test_runner,
++    MIDDLEWARE_CLASSES = (),
+ )
+ 
+-call_command('syncdb', verbosity=1, interactive=False)
++if django.VERSION[:2] > (1, 6):
++    django.setup()
++    call_command('migrate', verbosity=1, interactive=False)
++else:
++    call_command('syncdb', verbosity=1, interactive=False)
+ 
+ 
+ # ---- app start
+--- a/polymorphic/tests.py
++++ b/polymorphic/tests.py
+@@ -5,6 +5,7 @@
+ from __future__ import print_function
+ import uuid
+ import re
++import django
+ from django.db.models.query import QuerySet
+ 
+ from django.test import TestCase
+@@ -66,21 +67,45 @@
+ class ModelY(Base):
+     field_y = models.CharField(max_length=10)
+ 
+-class Enhance_Plain(models.Model):
+-    field_p = models.CharField(max_length=10)
+-class Enhance_Base(ShowFieldTypeAndContent, PolymorphicModel):
+-    field_b = models.CharField(max_length=10)
+-class Enhance_Inherit(Enhance_Base, Enhance_Plain):
+-    field_i = models.CharField(max_length=10)
+-
+-class DiamondBase(models.Model):
+-    field_b = models.CharField(max_length=10)
+-class DiamondX(DiamondBase):
+-    field_x = models.CharField(max_length=10)
+-class DiamondY(DiamondBase):
+-    field_y = models.CharField(max_length=10)
+-class DiamondXY(DiamondX, DiamondY):
+-    pass
++if django.VERSION[:2] > (1, 6):
++    class Enhance_Plain(models.Model):
++        field_p = models.CharField(max_length=10)
++    class Enhance_Base(ShowFieldTypeAndContent, PolymorphicModel):
++        base_id = models.AutoField(primary_key=True)
++        field_b = models.CharField(max_length=10)
++    class Enhance_Inherit(Enhance_Base, Enhance_Plain):
++        field_i = models.CharField(max_length=10)
++
++    class DiamondBase(models.Model):
++        field_b = models.CharField(max_length=10)
++    class DiamondX(DiamondBase):
++        x_id = models.AutoField(primary_key=True)
++        field_x = models.CharField(max_length=10)
++    class DiamondY(DiamondBase):
++        y_id = models.AutoField(primary_key=True)
++        field_y = models.CharField(max_length=10)
++    class DiamondXY(DiamondBase):
++        xy_id = models.AutoField(primary_key=True)
++        field_x = models.CharField(max_length=10)
++        field_y = models.CharField(max_length=10)
++else:
++    class Enhance_Plain(models.Model):
++        field_p = models.CharField(max_length=10)
++    class Enhance_Base(ShowFieldTypeAndContent, PolymorphicModel):
++        field_b = models.CharField(max_length=10)
++    class Enhance_Inherit(Enhance_Base, Enhance_Plain):
++        field_i = models.CharField(max_length=10)
++
++    class DiamondBase(models.Model):
++        field_b = models.CharField(max_length=10)
++    class DiamondX(DiamondBase):
++        x_id = models.AutoField(primary_key=True)
++        field_x = models.CharField(max_length=10)
++    class DiamondY(DiamondBase):
++        y_id = models.AutoField(primary_key=True)
++        field_y = models.CharField(max_length=10)
++    class DiamondXY(DiamondX, DiamondY):
++        xy_id = models.AutoField(primary_key=True)
+ 
+ class RelationBase(ShowFieldTypeAndContent, PolymorphicModel):
+     field_base = models.CharField(max_length=10)
+@@ -110,6 +135,9 @@
+ class MyManager(PolymorphicManager):
+     queryset_class = MyManagerQuerySet
+ 
++    def get_queryset(self):
++        return super(MyManager, self).get_queryset().order_by('-field1')
++
+     def get_query_set(self):
+         return super(MyManager, self).get_query_set().order_by('-field1')
+ 
+@@ -143,9 +171,12 @@
+     def my_queryset_foo(self):
+         return self.get_query_set().my_queryset_foo()
+ 
+-    def get_query_set(self):
++    def get_queryset(self):
+         return PlainMyManagerQuerySet(self.model, using=self._db)
+ 
++    def get_query_set(self):
++        return self.get_queryset()
++
+ class PlainParentModelWithManager(models.Model):
+     pass
+ 
+@@ -254,6 +285,10 @@
+     The test suite
+     """
+     def test_diamond_inheritance(self):
++        if django.VERSION[:2] > (1, 6):
++            print('')
++            print("# Django 1.7 doesn't allow multiple inheritance when two id fields exist. https://docs.djangoproject.com/en/dev/topics/db/models/#multiple-inheritance")
++
+         # Django diamond problem
+         # https://code.djangoproject.com/ticket/10808
+         o1 = DiamondXY.objects.create(field_b='b', field_x='x', field_y='y')
+@@ -616,11 +651,14 @@
+         Enhance_Inherit.objects.create(field_b='b-inherit', field_p='p', field_i='i')
+ 
+         qs = Enhance_Base.objects.all()
+-        self.assertEqual(repr(qs[0]), '<Enhance_Base: id 1, field_b (CharField) "b-base">')
+-        self.assertEqual(repr(qs[1]), '<Enhance_Inherit: id 2, field_b (CharField) "b-inherit", field_p (CharField) "p", field_i (CharField) "i">')
++        if django.VERSION[:2] > (1, 6):
++            self.assertEqual(repr(qs[0]), '<Enhance_Base: base_id (AutoField/pk) 1, field_b (CharField) "b-base">')
++            self.assertEqual(repr(qs[1]), '<Enhance_Inherit: base_id (AutoField/pk) 2, field_b (CharField) "b-inherit", id 1, field_p (CharField) "p", field_i (CharField) "i">')
++        else:
++            self.assertEqual(repr(qs[0]), '<Enhance_Base: id 1, field_b (CharField) "b-base">')
++            self.assertEqual(repr(qs[1]), '<Enhance_Inherit: id 2, field_b (CharField) "b-inherit", field_p (CharField) "p", field_i (CharField) "i">')
+         self.assertEqual(len(qs), 2)
+ 
+-
+     def test_relation_base(self):
+         # ForeignKey, ManyToManyField
+         obase = RelationBase.objects.create(field_base='base')
+--- a/docs/managers.rst
++++ b/docs/managers.rst
+@@ -13,12 +13,12 @@
+     from polymorphic import PolymorphicModel, PolymorphicManager
+ 
+    class TimeOrderedManager(PolymorphicManager):
+-        def get_query_set(self):
+-            qs = super(TimeOrderedManager,self).get_query_set()
++        def get_queryset(self):
++            qs = super(TimeOrderedManager,self).get_queryset()
+             return qs.order_by('-start_date')        # order the queryset
+ 
+         def most_recent(self):
+-            qs = self.get_query_set()                # get my ordered queryset
++            qs = self.get_queryset()                # get my ordered queryset
+             return qs[:10]                           # limit => get ten most recent entries
+ 
+     class Project(PolymorphicModel):
+@@ -31,6 +31,8 @@
+ related objects. It must not filter objects and it's safest to use
+ the plain ``PolymorphicManager`` here.
+ 
++    Note that get_query_set is deprecated in Django 1.8 and creates warnings in Django 1.7.
++
+ Manager Inheritance
+ -------------------
+ 
+@@ -42,12 +44,12 @@
+    from polymorphic import PolymorphicModel, PolymorphicManager
+ 
+    class TimeOrderedManager(PolymorphicManager):
+-        def get_query_set(self):
+-            qs = super(TimeOrderedManager,self).get_query_set()
++        def get_queryset(self):
++            qs = super(TimeOrderedManager,self).get_queryset()
+             return qs.order_by('-start_date')        # order the queryset
+ 
+         def most_recent(self):
+-            qs = self.get_query_set()                # get my ordered queryset
++            qs = self.get_queryset()                # get my ordered queryset
+             return qs[:10]                           # limit => get ten most recent entries
+ 
+     class Project(PolymorphicModel):
+@@ -65,6 +67,8 @@
+ will return the ten most recent art projects.
+ .
+ 
++    Note that get_query_set is deprecated in Django 1.8 and creates warnings in Django 1.7.
++
+ Using a Custom Queryset Class
+ -----------------------------
+ 
+--- a/tox.ini
++++ b/tox.ini
+@@ -7,12 +7,15 @@
+     py27-django14,
+     py27-django15,
+     py27-django16,
++    py27-django17,
+ 
+     py32-django15,
+     py32-django16,
++    py32-django17,
+ 
+     py33-django15,
+     py33-django16,
++    py33-django17,
+ 
+     py33-django-dev,
+     docs,
+@@ -53,6 +56,11 @@
+ deps=
+     django==1.6
+ 
++[testenv:py27-django17]
++basepython=python2.7
++deps=
++    django==1.7
++
+ [testenv:py32-django15]
+ basepython=python3.2
+ deps=
+@@ -63,6 +71,11 @@
+ deps=
+     django==1.6
+ 
++[testenv:py32-django17]
++basepython=python3.2
++deps=
++    django==1.7
++
+ [testenv:py33-django15]
+ basepython=python3.3
+ deps=
+@@ -73,6 +86,11 @@
+ deps=
+     django==1.6
+ 
++[testenv:py33-django17]
++basepython=python3.3
++deps=
++    django==1.7
++
+ [testenv:py33-django-dev]
+ basepython=python3.3
+ deps=
+--- a/.travis.yml
++++ b/.travis.yml
+@@ -8,6 +8,7 @@
+   - DJANGO=django==1.4.5
+   - DJANGO=django==1.5
+   - DJANGO=django==1.6
++  - DJANGO=django==1.7
+   #- DJANGO=https://github.com/django/django/archive/stable/1.6.x.zip
+ 
+ matrix:
+@@ -16,6 +17,8 @@
+     env: DJANGO=django==1.4.5
+   - python: "3.2"
+     env: DJANGO=django==1.4.5
++  - python: "2.6"
++    env: DJANGO=django==1.7
+ 
+ install:
+   - pip install $DJANGO coverage==3.6

Added: packages/django-polymorphic/trunk/debian/patches/series
===================================================================
--- packages/django-polymorphic/trunk/debian/patches/series	                        (rev 0)
+++ packages/django-polymorphic/trunk/debian/patches/series	2014-09-19 20:16:35 UTC (rev 30675)
@@ -0,0 +1 @@
+django-1.7.patch




More information about the Python-modules-commits mailing list