Django

Code

Changeset 2366

Show
Ignore:
Timestamp:
02/22/06 07:14:44 (3 years ago)
Author:
lukeplant
Message:

magic-removal: Added 'ordering' to models in m2m tests to make them more deterministic and fix a test that failed with MySQL

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/tests/modeltests/many_to_many/models.py

    r2307 r2366  
    1616        return self.title 
    1717 
     18    class Meta: 
     19        ordering = ('title',) 
     20 
    1821class Article(models.Model): 
    1922    headline = models.CharField(maxlength=100) 
     
    2225    def __repr__(self): 
    2326        return self.headline 
     27 
     28    class Meta: 
     29        ordering = ('headline',) 
    2430 
    2531API_TESTS = """ 
     
    5561[The Python Journal] 
    5662>>> a2.publications.all() 
    57 [The Python Journal, Science News, Science Weekly, Highlights for Children
     63[Highlights for Children, Science News, Science Weekly, The Python Journal
    5864 
    5965# Publication objects have access to their related Article objects. 
    6066>>> p2.article_set.all() 
    6167[NASA uses Python] 
    62 >>> p1.article_set.order_by('headline'
     68>>> p1.article_set.all(
    6369[Django lets you build Web apps easily, NASA uses Python] 
    6470>>> Publication.objects.get(id=4).article_set.all() 
     
    8591 
    8692>>> Publication.objects.filter(article__headline__startswith="NASA") 
    87 [The Python Journal, Science News, Science Weekly, Highlights for Children
     93[Highlights for Children, Science News, Science Weekly, The Python Journal
    8894 
    8995>>> Publication.objects.filter(article__id__exact=1) 
     
    96102>>> p1.delete() 
    97103>>> Publication.objects.all() 
    98 [Science News, Science Weekly, Highlights for Children
     104[Highlights for Children, Science News, Science Weekly
    99105>>> a1 = Article.objects.get(pk=1) 
    100106>>> a1.publications.all() 
     
    105111>>> Article.objects.all() 
    106112[Django lets you build Web apps easily] 
    107 >>> p1.article_set.order_by('headline'
     113>>> p1.article_set.all(
    108114[Django lets you build Web apps easily] 
    109115 
     
    119125# Adding via the other end using keywords 
    120126>>> p2.article_set.add(headline='Oxygen-free diet works wonders') 
    121 >>> p2.article_set.all().order_by('headline') 
     127>>> p2.article_set.all() 
    122128[NASA finds intelligent life on Earth, Oxygen-free diet works wonders] 
    123 >>> a5 = p2.article_set.all().order_by('headline')[1] 
     129>>> a5 = p2.article_set.all()[1] 
    124130>>> a5.publications.all() 
    125131[Science News] 
     
    127133# Removing publication from an article: 
    128134>>> a4.publications.remove(p2) 
    129 >>> p2.article_set.all().order_by('headline') 
     135>>> p2.article_set.all() 
    130136[Oxygen-free diet works wonders] 
    131137>>> a4.publications.all() 
     
    134140# And from the other end 
    135141>>> p2.article_set.remove(a5) 
    136 >>> p2.article_set.order_by('headline'
     142>>> p2.article_set.all(
    137143[] 
    138144>>> a5.publications.all() 
     
    143149>>> p2.article_set.add(a4, a5) 
    144150>>> a4.publications.add(p3) 
    145 >>> a4.publications.order_by('title'
     151>>> a4.publications.all(
    146152[Science News, Science Weekly] 
    147153>>> p2.article_set.clear() 
     
    153159# And you can clear from the other end 
    154160>>> p2.article_set.add(a4, a5) 
    155 >>> p2.article_set.all().order_by('headline') 
     161>>> p2.article_set.all() 
    156162[NASA finds intelligent life on Earth, Oxygen-free diet works wonders] 
    157 >>> a4.publications.order_by('title'
     163>>> a4.publications.all(
    158164[Science News, Science Weekly] 
    159165>>> a4.publications.clear() 
    160166>>> a4.publications.all() 
    161167[] 
    162 >>> p2.article_set.all().order_by('headline') 
     168>>> p2.article_set.all() 
    163169[Oxygen-free diet works wonders] 
    164170 
     
    175181[Highlights for Children, The Python Journal] 
    176182>>> Article.objects.all() 
    177 [Django lets you build Web apps easily, NASA finds intelligent life on Earth, Oxygen-free diet works wonders, NASA uses Python
     183[Django lets you build Web apps easily, NASA finds intelligent life on Earth, NASA uses Python, Oxygen-free diet works wonders
    178184>>> a2.publications.all() 
    179185[The Python Journal]