Ticket #16759: 16759_test.diff

File 16759_test.diff, 1.4 KB (added by Anssi Kääriäinen, 13 years ago)
  • tests/regressiontests/queries/tests.py

    diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
    index ded3e8f..e9ccf27 100644
    a b import sys  
    77from django.conf import settings
    88from django.core.exceptions import FieldError
    99from django.db import DatabaseError, connection, connections, DEFAULT_DB_ALIAS
    10 from django.db.models import Count
     10from django.db.models import Count, F
    1111from django.db.models.query import Q, ITER_CHUNK_SIZE, EmptyQuerySet
    1212from django.test import TestCase, skipUnlessDBFeature
    1313from django.utils import unittest
    class CloneTests(TestCase):  
    16101610        except:
    16111611            self.fail('Query should be clonable')
    16121612
     1613    def test_clone_restricted(self):
     1614        """
     1615        Test that cloning a queryset does not get out of hand. While complete
     1616        testing is impossible, this is a sanity check against invalid use of
     1617        deepcopy. refs #16759.
     1618        """
     1619        qs = Note.objects.all().filter(pk__lte=F('pk') + 1)
     1620        orig_opts = qs.query.where.children[0].children[0][3].opts
     1621        # Lets clone it and see that the opts did not get cloned.
     1622        qs = qs.all()
     1623        new_opts = qs.query.where.children[0].children[0][3].opts
     1624        self.assertTrue(orig_opts is new_opts)
    16131625
    16141626class EmptyQuerySetTests(TestCase):
    16151627    def test_emptyqueryset_values(self):
Back to Top