~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to tests/regressiontests/m2m_regress/tests.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2012-03-31 14:48:00 UTC
  • mfrom: (1.2.12)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: package-import@ubuntu.com-20120331144800-6a44u7d8z6pd2br4
Tags: upstream-1.4
Import upstream version 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import absolute_import
 
2
 
1
3
from django.core.exceptions import FieldError
2
4
from django.test import TestCase
3
5
 
4
 
from models import (SelfRefer, Tag, TagCollection, Entry, SelfReferChild,
 
6
from .models import (SelfRefer, Tag, TagCollection, Entry, SelfReferChild,
5
7
    SelfReferChildSibling, Worksheet)
6
8
 
7
9
 
73
75
 
74
76
        self.assertQuerysetEqual(c1.tags.all(), ["<Tag: t1>", "<Tag: t2>"])
75
77
        self.assertQuerysetEqual(t1.tag_collections.all(), ["<TagCollection: c1>"])
 
78
 
 
79
    def test_manager_class_caching(self):
 
80
        e1 = Entry.objects.create()
 
81
        e2 = Entry.objects.create()
 
82
        t1 = Tag.objects.create()
 
83
        t2 = Tag.objects.create()
 
84
 
 
85
        # Get same manager twice in a row:
 
86
        self.assertTrue(t1.entry_set.__class__ is t1.entry_set.__class__)
 
87
        self.assertTrue(e1.topics.__class__ is e1.topics.__class__)
 
88
 
 
89
        # Get same manager for different instances
 
90
        self.assertTrue(e1.topics.__class__ is e2.topics.__class__)
 
91
        self.assertTrue(t1.entry_set.__class__ is t2.entry_set.__class__)