Convert all modeltests to use absolute imports, rather than relative ones.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16975 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
99512d3544
commit
d5a45d79fe
|
@ -1,10 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
from django.db.models import Avg, Sum, Count, Max, Min
|
||||
from django.test import TestCase, Approximate
|
||||
|
||||
from models import Author, Publisher, Book, Store
|
||||
from .models import Author, Publisher, Book, Store
|
||||
|
||||
|
||||
class BaseAggregateTestCase(TestCase):
|
||||
|
|
|
@ -6,6 +6,7 @@ This is a basic model with only two non-primary-key fields.
|
|||
"""
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
headline = models.CharField(max_length=100, default='Default headline')
|
||||
pub_date = models.DateTimeField()
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db.models.fields import FieldDoesNotExist
|
||||
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
|
||||
|
||||
from models import Article
|
||||
from .models import Article
|
||||
|
||||
|
||||
class ModelTest(TestCase):
|
||||
|
|
|
@ -11,6 +11,7 @@ field. This method returns the "human-readable" value of the field.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
GENDER_CHOICES = (
|
||||
('M', 'Male'),
|
||||
('F', 'Female'),
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Person
|
||||
from .models import Person
|
||||
|
||||
|
||||
class ChoicesTests(TestCase):
|
||||
|
@ -9,10 +11,10 @@ class ChoicesTests(TestCase):
|
|||
s = Person.objects.create(name='Sara', gender='F')
|
||||
self.assertEqual(a.gender, 'M')
|
||||
self.assertEqual(s.gender, 'F')
|
||||
|
||||
|
||||
self.assertEqual(a.get_gender_display(), 'Male')
|
||||
self.assertEqual(s.get_gender_display(), 'Female')
|
||||
|
||||
|
||||
# If the value for the field doesn't correspond to a valid choice,
|
||||
# the value itself is provided as a display value.
|
||||
a.gender = ''
|
||||
|
|
|
@ -17,6 +17,7 @@ from the default generated name, use the ``db_table`` parameter on the
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Author(models.Model):
|
||||
first_name = models.CharField(max_length=30, db_column='firstname')
|
||||
last_name = models.CharField(max_length=30, db_column='last')
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.core.exceptions import FieldError
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Author, Article
|
||||
from .models import Author, Article
|
||||
|
||||
|
||||
class CustomColumnsTests(TestCase):
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Person, Book, Car, PersonManager, PublishedBookManager
|
||||
from .models import Person, Book, Car, PersonManager, PublishedBookManager
|
||||
|
||||
|
||||
class CustomManagerTests(TestCase):
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
Any method you add to a model will be available to instances.
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
import datetime
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
headline = models.CharField(max_length=100)
|
||||
pub_date = models.DateField()
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import date
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article
|
||||
from .models import Article
|
||||
|
||||
|
||||
class MethodsTests(TestCase):
|
||||
|
|
|
@ -6,9 +6,12 @@ By default, Django adds an ``"id"`` field to each model. But you can override
|
|||
this behavior by explicitly adding ``primary_key=True`` to a field.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
|
||||
from fields import MyAutoField
|
||||
from .fields import MyAutoField
|
||||
|
||||
|
||||
class Employee(models.Model):
|
||||
employee_code = models.IntegerField(primary_key=True, db_column = 'code')
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import transaction, IntegrityError
|
||||
from django.test import TestCase, skipIfDBFeature
|
||||
|
||||
from models import Employee, Business, Bar, Foo
|
||||
from .models import Employee, Business, Bar, Foo
|
||||
|
||||
|
||||
class CustomPKTests(TestCase):
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.db.models.query_utils import DeferredAttribute
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Secondary, Primary, Child, BigChild
|
||||
from .models import Secondary, Primary, Child, BigChild
|
||||
|
||||
|
||||
class DeferTests(TestCase):
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models, IntegrityError
|
||||
from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
|
||||
|
||||
from modeltests.delete.models import (R, RChild, S, T, U, A, M, MR, MRNull,
|
||||
from .models import (R, RChild, S, T, U, A, M, MR, MRNull,
|
||||
create_a, get_default_r, User, Avatar, HiddenUser, HiddenUserProfile)
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.test import TestCase
|
||||
|
||||
|
||||
class NoModelTests(TestCase):
|
||||
""" A placeholder test case. See modeltests.empty.tests for more info. """
|
||||
pass
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
@ -6,7 +6,7 @@ from django.db.models.loading import get_app
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from models import Empty
|
||||
from .models import Empty
|
||||
|
||||
|
||||
class EmptyModelTests(TestCase):
|
||||
|
|
|
@ -4,6 +4,7 @@ Tests for F() query expression syntax.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Employee(models.Model):
|
||||
firstname = models.CharField(max_length=50)
|
||||
lastname = models.CharField(max_length=50)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.core.exceptions import FieldError
|
||||
from django.db.models import F
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Company, Employee
|
||||
from .models import Company, Employee
|
||||
|
||||
|
||||
class ExpressionsTests(TestCase):
|
||||
|
|
|
@ -10,9 +10,11 @@ This example uses ``datetime.datetime.now`` as the default for the ``pub_date``
|
|||
field.
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
from datetime import datetime
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
headline = models.CharField(max_length=100, default='Default headline')
|
||||
pub_date = models.DateTimeField(default=datetime.now)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article
|
||||
from .models import Article
|
||||
|
||||
|
||||
class DefaultTests(TestCase):
|
||||
|
|
|
@ -2,6 +2,7 @@ from django.db import models
|
|||
from django.utils import simplejson as json
|
||||
from django.utils.encoding import force_unicode
|
||||
|
||||
|
||||
class Small(object):
|
||||
"""
|
||||
A simple class to show that non-trivial Python objects can be used as
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
Tests for field subclassing.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_unicode
|
||||
|
||||
from fields import SmallField, SmallerField, JSONField
|
||||
from .fields import SmallField, SmallerField, JSONField
|
||||
|
||||
|
||||
class MyModel(models.Model):
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.core import serializers
|
||||
from django.test import TestCase
|
||||
|
||||
from fields import Small
|
||||
from models import DataModel, MyModel, OtherModel
|
||||
from .fields import Small
|
||||
from .models import DataModel, MyModel, OtherModel
|
||||
|
||||
|
||||
class CustomField(TestCase):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
import shutil
|
||||
import tempfile
|
||||
|
@ -9,7 +9,7 @@ from django.core.files.base import ContentFile
|
|||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Storage, temp_storage, temp_storage_location
|
||||
from .models import Storage, temp_storage, temp_storage_location
|
||||
|
||||
|
||||
class FileTests(TestCase):
|
||||
|
|
|
@ -8,10 +8,10 @@ in the application directory, or in one of the directories named in the
|
|||
``FIXTURE_DIRS`` setting.
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Category(models.Model):
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import StringIO
|
||||
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core import management
|
||||
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
|
||||
|
||||
from models import Article, Book, Spy, Tag, Visa
|
||||
from .models import Article, Book, Spy, Tag, Visa
|
||||
|
||||
|
||||
class TestCaseFixtureLoadingTests(TestCase):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
headline = models.CharField(max_length=100, default='Default headline')
|
||||
pub_date = models.DateTimeField()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.core import management
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article
|
||||
from .models import Article
|
||||
|
||||
|
||||
class SampleTestCase(TestCase):
|
||||
|
|
|
@ -4,6 +4,7 @@ automatic behaviour).
|
|||
"""
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Counter(models.Model):
|
||||
name = models.CharField(max_length = 10)
|
||||
value = models.IntegerField()
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.db import transaction, IntegrityError, DatabaseError
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Counter, WithCustomPK
|
||||
from .models import Counter, WithCustomPK
|
||||
|
||||
|
||||
class ForceTests(TestCase):
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django import forms
|
||||
from django.contrib.contenttypes.generic import generic_inlineformset_factory
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
|
||||
from .models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
|
||||
Vegetable, Mineral, Gecko)
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ farthest into the future."
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
headline = models.CharField(max_length=100)
|
||||
pub_date = models.DateField()
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article, Person
|
||||
from .models import Article, Person
|
||||
|
||||
|
||||
class LatestTests(TestCase):
|
||||
|
|
|
@ -12,6 +12,7 @@ performing a ``filter()`` lookup and raising a ``Http404`` exception if a
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Author(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.http import Http404
|
||||
from django.shortcuts import get_object_or_404, get_list_or_404
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Author, Article
|
||||
from .models import Author, Article
|
||||
|
||||
|
||||
class GetObjectOr404Tests(TestCase):
|
||||
|
|
|
@ -8,6 +8,7 @@ parameters.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Person(models.Model):
|
||||
first_name = models.CharField(max_length=100)
|
||||
last_name = models.CharField(max_length=100)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import date
|
||||
|
||||
from django.db import IntegrityError
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Person, ManualPrimaryKeyTest
|
||||
from .models import Person, ManualPrimaryKeyTest
|
||||
|
||||
|
||||
class GetOrCreateTests(TestCase):
|
||||
|
|
|
@ -7,6 +7,7 @@ This example exists purely to point out errors in models.
|
|||
|
||||
from django.db import connection, models
|
||||
|
||||
|
||||
class FieldErrors(models.Model):
|
||||
charfield = models.CharField()
|
||||
charfield2 = models.CharField(max_length=-1)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import copy
|
||||
import sys
|
||||
from cStringIO import StringIO
|
||||
|
||||
from django.core.management.validation import get_validation_errors
|
||||
from django.db.models.loading import cache, load_app
|
||||
from cStringIO import StringIO
|
||||
import sys
|
||||
|
||||
from django.utils import unittest
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ This demonstrates features of the database API.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Author(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
class Meta:
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
from operator import attrgetter
|
||||
|
||||
from django.core.exceptions import FieldError
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
from models import Author, Article, Tag
|
||||
|
||||
from .models import Author, Article, Tag
|
||||
|
||||
|
||||
class LookupTests(TestCase):
|
||||
|
@ -243,7 +247,7 @@ class LookupTests(TestCase):
|
|||
self.assertQuerysetEqual(Article.objects.filter(id=self.a5.id).values(),
|
||||
[{
|
||||
'id': self.a5.id,
|
||||
'author_id': self.au2.id,
|
||||
'author_id': self.au2.id,
|
||||
'headline': 'Article 5',
|
||||
'pub_date': datetime(2005, 8, 1, 9, 0)
|
||||
}], transform=identity)
|
||||
|
|
|
@ -6,6 +6,7 @@ Make sure to set ``related_name`` if you use relationships to the same table.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class User(models.Model):
|
||||
username = models.CharField(max_length=20)
|
||||
|
||||
|
@ -20,6 +21,6 @@ class Issue(models.Model):
|
|||
class Meta:
|
||||
ordering = ('num',)
|
||||
|
||||
class UnicodeReferenceModel(models.Model):
|
||||
others = models.ManyToManyField(u"UnicodeReferenceModel")
|
||||
class UnicodeReferenceModel(models.Model):
|
||||
others = models.ManyToManyField(u"UnicodeReferenceModel")
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.db.models import Q
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Issue, User, UnicodeReferenceModel
|
||||
from .models import Issue, User, UnicodeReferenceModel
|
||||
|
||||
|
||||
class RelatedObjectTests(TestCase):
|
||||
|
@ -74,15 +76,15 @@ class RelatedObjectTests(TestCase):
|
|||
lambda i: i.num
|
||||
)
|
||||
|
||||
class RelatedObjectTests(TestCase):
|
||||
def test_m2m_with_unicode_reference(self):
|
||||
class RelatedObjectTests(TestCase):
|
||||
def test_m2m_with_unicode_reference(self):
|
||||
"""
|
||||
Regression test for #6045: references to other models can be unicode
|
||||
strings, providing they are directly convertible to ASCII.
|
||||
"""
|
||||
m1=UnicodeReferenceModel.objects.create()
|
||||
m2=UnicodeReferenceModel.objects.create()
|
||||
m2.others.add(m1) # used to cause an error (see ticket #6045)
|
||||
m2.save()
|
||||
m1=UnicodeReferenceModel.objects.create()
|
||||
m2=UnicodeReferenceModel.objects.create()
|
||||
m2.others.add(m1) # used to cause an error (see ticket #6045)
|
||||
m2.save()
|
||||
list(m2.others.all()) # Force retrieval.
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ field, which specifies the ``Reporter``'s position for the given article
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Reporter(models.Model):
|
||||
first_name = models.CharField(max_length=30)
|
||||
last_name = models.CharField(max_length=30)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Reporter, Article, Writer
|
||||
from .models import Reporter, Article, Writer
|
||||
|
||||
|
||||
class M2MIntermediaryTests(TestCase):
|
||||
|
|
|
@ -9,6 +9,7 @@ Set ``related_name`` to designate what the reverse relationship is called.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Category(models.Model):
|
||||
name = models.CharField(max_length=20)
|
||||
class Meta:
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article, Category
|
||||
from .models import Article, Category
|
||||
|
||||
|
||||
class M2MMultipleTests(TestCase):
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from operator import attrgetter
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Person
|
||||
from .models import Person
|
||||
|
||||
|
||||
class RecursiveM2MTests(TestCase):
|
||||
|
@ -11,14 +13,14 @@ class RecursiveM2MTests(TestCase):
|
|||
Person.objects.create(name=name)
|
||||
for name in ["Anne", "Bill", "Chuck", "David"]
|
||||
]
|
||||
|
||||
|
||||
# Add some friends in the direction of field definition
|
||||
# Anne is friends with Bill and Chuck
|
||||
a.friends.add(b, c)
|
||||
|
||||
# David is friends with Anne and Chuck - add in reverse direction
|
||||
d.friends.add(a,c)
|
||||
|
||||
|
||||
# Who is friends with Anne?
|
||||
self.assertQuerysetEqual(
|
||||
a.friends.all(), [
|
||||
|
@ -54,7 +56,7 @@ class RecursiveM2MTests(TestCase):
|
|||
# Bill is already friends with Anne - add Anne again, but in the
|
||||
# reverse direction
|
||||
b.friends.add(a)
|
||||
|
||||
|
||||
# Who is friends with Anne?
|
||||
self.assertQuerysetEqual(
|
||||
a.friends.all(), [
|
||||
|
@ -115,7 +117,7 @@ class RecursiveM2MTests(TestCase):
|
|||
b.idols.add(a)
|
||||
# David is idolized by Anne and Chuck - add in reverse direction
|
||||
d.stalkers.add(a, c)
|
||||
|
||||
|
||||
# Who are Anne's idols?
|
||||
self.assertQuerysetEqual(
|
||||
a.idols.all(), [
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
Testing signals emitted on changing m2m relations.
|
||||
"""
|
||||
|
||||
from .models import Person
|
||||
|
||||
from django.db import models
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Part, Car, SportsCar, Person
|
||||
from .models import Part, Car, SportsCar, Person
|
||||
|
||||
|
||||
class ManyToManySignalsTest(TestCase):
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from django.db import models
|
||||
from datetime import datetime
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
# M2M described on one of the models
|
||||
class Person(models.Model):
|
||||
name = models.CharField(max_length=128)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
from operator import attrgetter
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import (Person, Group, Membership, CustomMembership,
|
||||
from .models import (Person, Group, Membership, CustomMembership,
|
||||
PersonSelfRefM2M, Friendship)
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ Set ``related_name`` to designate what the reverse relationship is called.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Category(models.Model):
|
||||
name = models.CharField(max_length=20)
|
||||
parent = models.ForeignKey('self', blank=True, null=True, related_name='child_set')
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
from models import Category, Person
|
||||
|
||||
from .models import Category, Person
|
||||
|
||||
|
||||
class ManyToOneRecursiveTests(TestCase):
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ objects, and a ``Publication`` has multiple ``Article`` objects.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Publication(models.Model):
|
||||
title = models.CharField(max_length=30)
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
from models import Article, Publication
|
||||
|
||||
from .models import Article, Publication
|
||||
|
||||
|
||||
class ManyToManyTests(TestCase):
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ To define a many-to-one relationship, use ``ForeignKey()``.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Reporter(models.Model):
|
||||
first_name = models.CharField(max_length=30)
|
||||
last_name = models.CharField(max_length=30)
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from copy import deepcopy
|
||||
from datetime import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
from django.core.exceptions import MultipleObjectsReturned
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article, Reporter
|
||||
from .models import Article, Reporter
|
||||
|
||||
|
||||
class ManyToOneTests(TestCase):
|
||||
|
|
|
@ -7,6 +7,7 @@ To define a many-to-one relationship that can have a null foreign key, use
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Reporter(models.Model):
|
||||
name = models.CharField(max_length=30)
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
from models import Reporter, Article
|
||||
|
||||
from .models import Reporter, Article
|
||||
|
||||
|
||||
class ManyToOneNullTests(TestCase):
|
||||
|
|
|
@ -9,8 +9,9 @@ words, most of these tests should be rewritten.
|
|||
|
||||
import tempfile
|
||||
|
||||
from django.db import models
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.db import models
|
||||
|
||||
|
||||
temp_storage_dir = tempfile.mkdtemp()
|
||||
temp_storage = FileSystemStorage(temp_storage_dir)
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
import datetime
|
||||
import os
|
||||
from decimal import Decimal
|
||||
|
||||
from django import forms
|
||||
from django.test import TestCase
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.core.validators import ValidationError
|
||||
from django.db import connection
|
||||
from django.forms.models import model_to_dict
|
||||
from django.utils.unittest import skipUnless
|
||||
from django.test import TestCase
|
||||
|
||||
from modeltests.model_forms.models import (Article, ArticleStatus,
|
||||
BetterWriter, BigInt, Book, Category, CommaSeparatedInteger,
|
||||
CustomFieldForExclusionModel, DerivedBook, DerivedPost, ExplicitPK,
|
||||
FlexibleDatePost, ImprovedArticle, ImprovedArticleWithParentLink,
|
||||
Inventory, PhoneNumber, Post, Price, Product, TextFile, Writer,
|
||||
WriterProfile, test_images)
|
||||
from .models import (Article, ArticleStatus, BetterWriter, BigInt, Book,
|
||||
Category, CommaSeparatedInteger, CustomFieldForExclusionModel, DerivedBook,
|
||||
DerivedPost, ExplicitPK, FlexibleDatePost, ImprovedArticle,
|
||||
ImprovedArticleWithParentLink, Inventory, PhoneNumber, Post, Price,
|
||||
Product, TextFile, Writer, WriterProfile, test_images)
|
||||
|
||||
if test_images:
|
||||
from modeltests.model_forms.models import ImageFile, OptionalImageFile
|
||||
from .models import ImageFile, OptionalImageFile
|
||||
class ImageFileForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = ImageFile
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import datetime
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Author(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
import re
|
||||
from datetime import date
|
||||
|
@ -9,13 +11,13 @@ from django.forms.models import (_get_foreign_key, inlineformset_factory,
|
|||
modelformset_factory)
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
|
||||
from modeltests.model_formsets.models import (
|
||||
Author, BetterAuthor, Book, BookWithCustomPK,
|
||||
from .models import (Author, BetterAuthor, Book, BookWithCustomPK,
|
||||
BookWithOptionalAltEditor, AlternateBook, AuthorMeeting, CustomPrimaryKey,
|
||||
Place, Owner, Location, OwnerProfile, Restaurant, Product, Price,
|
||||
MexicanRestaurant, ClassyMexicanRestaurant, Repository, Revision,
|
||||
Person, Membership, Team, Player, Poet, Poem, Post)
|
||||
|
||||
|
||||
class DeletionTests(TestCase):
|
||||
def test_deletion(self):
|
||||
PoetFormSet = modelformset_factory(Poet, can_delete=True)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from operator import attrgetter
|
||||
|
||||
from django.core.exceptions import FieldError
|
||||
from django.test import TestCase
|
||||
|
||||
from models import (Chef, CommonInfo, ItalianRestaurant, ParkingLot, Place,
|
||||
from .models import (Chef, CommonInfo, ItalianRestaurant, ParkingLot, Place,
|
||||
Post, Restaurant, Student, StudentWorker, Supplier, Worker, MixinModel)
|
||||
|
||||
|
||||
|
|
|
@ -6,8 +6,11 @@ in the need for an %(app_label)s format string. This app specifically tests
|
|||
this feature by redefining the Copy model from model_inheritance/models.py
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
from modeltests.model_inheritance.models import NamedURL
|
||||
|
||||
from ..model_inheritance.models import NamedURL
|
||||
|
||||
#
|
||||
# Abstract base classes with related models
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
from modeltests.model_inheritance.models import Title
|
||||
|
||||
from ..model_inheritance.models import Title
|
||||
|
||||
|
||||
class InheritanceSameModelNameTests(TestCase):
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Import all the models from subpackages
|
||||
from article import Article
|
||||
from publication import Publication
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .article import Article
|
||||
from .publication import Publication
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
from django.contrib.sites.models import Site
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
sites = models.ManyToManyField(Site)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Publication(models.Model):
|
||||
title = models.CharField(max_length=30)
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.sites.models import Site
|
||||
from django.db import models
|
||||
from django.test import TestCase
|
||||
|
||||
from models.publication import Publication
|
||||
from models.article import Article
|
||||
from .models.publication import Publication
|
||||
from .models.article import Article
|
||||
|
||||
|
||||
class Advertisment(models.Model):
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
from models import Parent
|
||||
|
||||
from .models import Parent
|
||||
|
||||
|
||||
class MutuallyReferentialTests(TestCase):
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ In this example, a ``Place`` optionally can be a ``Restaurant``.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Place(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
address = models.CharField(max_length=80)
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
from django.test import TestCase
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import transaction, IntegrityError
|
||||
from models import Place, Restaurant, Waiter, ManualPrimaryKey, RelatedModel, MultiModel
|
||||
from django.test import TestCase
|
||||
|
||||
from .models import (Place, Restaurant, Waiter, ManualPrimaryKey, RelatedModel,
|
||||
MultiModel)
|
||||
|
||||
class OneToOneTests(TestCase):
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ clauses using the variable ``django.db.models.Q`` (or any object with an
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
headline = models.CharField(max_length=50)
|
||||
pub_date = models.DateTimeField()
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
from operator import attrgetter
|
||||
|
||||
from django.db.models import Q
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article
|
||||
from .models import Article
|
||||
|
||||
|
||||
class OrLookupsTests(TestCase):
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from operator import attrgetter
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Post, Question, Answer
|
||||
from .models import Post, Question, Answer
|
||||
|
||||
|
||||
class OrderWithRespectToTests(TestCase):
|
||||
def test_basic(self):
|
||||
q1 = Question.objects.create(text="Which Beatle starts with the letter 'R'?")
|
||||
q2 = Question.objects.create(text="What is your name?")
|
||||
|
||||
|
||||
Answer.objects.create(text="John", question=q1)
|
||||
Answer.objects.create(text="Jonno", question=q2)
|
||||
Answer.objects.create(text="Paul", question=q1)
|
||||
Answer.objects.create(text="Paulo", question=q2)
|
||||
Answer.objects.create(text="George", question=q1)
|
||||
Answer.objects.create(text="Ringo", question=q1)
|
||||
|
||||
|
||||
# The answers will always be ordered in the order they were inserted.
|
||||
self.assertQuerysetEqual(
|
||||
q1.answer_set.all(), [
|
||||
|
@ -24,7 +26,7 @@ class OrderWithRespectToTests(TestCase):
|
|||
],
|
||||
attrgetter("text"),
|
||||
)
|
||||
|
||||
|
||||
# We can retrieve the answers related to a particular object, in the
|
||||
# order they were created, once we have a particular object.
|
||||
a1 = Answer.objects.filter(question=q1)[0]
|
||||
|
@ -34,20 +36,20 @@ class OrderWithRespectToTests(TestCase):
|
|||
a4 = list(Answer.objects.filter(question=q1))[-1]
|
||||
self.assertEqual(a4.text, "Ringo")
|
||||
self.assertEqual(a4.get_previous_in_order().text, "George")
|
||||
|
||||
|
||||
# Determining (and setting) the ordering for a particular item is also
|
||||
# possible.
|
||||
id_list = [o.pk for o in q1.answer_set.all()]
|
||||
self.assertEqual(a2.question.get_answer_order(), id_list)
|
||||
|
||||
|
||||
a5 = Answer.objects.create(text="Number five", question=q1)
|
||||
|
||||
|
||||
# It doesn't matter which answer we use to check the order, it will
|
||||
# always be the same.
|
||||
self.assertEqual(
|
||||
a2.question.get_answer_order(), a5.question.get_answer_order()
|
||||
)
|
||||
|
||||
|
||||
# The ordering can be altered:
|
||||
id_list = [o.pk for o in q1.answer_set.all()]
|
||||
x = id_list.pop()
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
from operator import attrgetter
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article
|
||||
from .models import Article
|
||||
|
||||
|
||||
class OrderingTests(TestCase):
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article
|
||||
from .models import Article
|
||||
|
||||
|
||||
class CountContainer(object):
|
||||
|
@ -20,13 +22,13 @@ class PaginationTests(TestCase):
|
|||
for x in range(1, 10):
|
||||
a = Article(headline='Article %s' % x, pub_date=datetime(2005, 7, 29))
|
||||
a.save()
|
||||
|
||||
|
||||
def test_paginator(self):
|
||||
paginator = Paginator(Article.objects.all(), 5)
|
||||
self.assertEqual(9, paginator.count)
|
||||
self.assertEqual(2, paginator.num_pages)
|
||||
self.assertEqual([1, 2], paginator.page_range)
|
||||
|
||||
|
||||
def test_first_page(self):
|
||||
paginator = Paginator(Article.objects.all(), 5)
|
||||
p = paginator.page(1)
|
||||
|
@ -46,7 +48,7 @@ class PaginationTests(TestCase):
|
|||
self.assertEqual(0, p.previous_page_number())
|
||||
self.assertEqual(1, p.start_index())
|
||||
self.assertEqual(5, p.end_index())
|
||||
|
||||
|
||||
def test_last_page(self):
|
||||
paginator = Paginator(Article.objects.all(), 5)
|
||||
p = paginator.page(2)
|
||||
|
@ -65,41 +67,41 @@ class PaginationTests(TestCase):
|
|||
self.assertEqual(1, p.previous_page_number())
|
||||
self.assertEqual(6, p.start_index())
|
||||
self.assertEqual(9, p.end_index())
|
||||
|
||||
|
||||
def test_empty_page(self):
|
||||
paginator = Paginator(Article.objects.all(), 5)
|
||||
self.assertRaises(EmptyPage, paginator.page, 0)
|
||||
self.assertRaises(EmptyPage, paginator.page, 3)
|
||||
|
||||
|
||||
# Empty paginators with allow_empty_first_page=True.
|
||||
paginator = Paginator(Article.objects.filter(id=0), 5, allow_empty_first_page=True)
|
||||
self.assertEqual(0, paginator.count)
|
||||
self.assertEqual(1, paginator.num_pages)
|
||||
self.assertEqual([1], paginator.page_range)
|
||||
|
||||
|
||||
# Empty paginators with allow_empty_first_page=False.
|
||||
paginator = Paginator(Article.objects.filter(id=0), 5, allow_empty_first_page=False)
|
||||
self.assertEqual(0, paginator.count)
|
||||
self.assertEqual(0, paginator.num_pages)
|
||||
self.assertEqual([], paginator.page_range)
|
||||
|
||||
|
||||
def test_invalid_page(self):
|
||||
paginator = Paginator(Article.objects.all(), 5)
|
||||
self.assertRaises(InvalidPage, paginator.page, 7)
|
||||
|
||||
|
||||
def test_orphans(self):
|
||||
# Add a few more records to test out the orphans feature.
|
||||
for x in range(10, 13):
|
||||
Article(headline="Article %s" % x, pub_date=datetime(2006, 10, 6)).save()
|
||||
|
||||
|
||||
# With orphans set to 3 and 10 items per page, we should get all 12 items on a single page.
|
||||
paginator = Paginator(Article.objects.all(), 10, orphans=3)
|
||||
self.assertEqual(1, paginator.num_pages)
|
||||
|
||||
|
||||
# With orphans only set to 1, we should get two pages.
|
||||
paginator = Paginator(Article.objects.all(), 10, orphans=1)
|
||||
self.assertEqual(2, paginator.num_pages)
|
||||
|
||||
|
||||
def test_paginate_list(self):
|
||||
# Paginators work with regular lists/tuples, too -- not just with QuerySets.
|
||||
paginator = Paginator([1, 2, 3, 4, 5, 6, 7, 8, 9], 5)
|
||||
|
@ -116,14 +118,14 @@ class PaginationTests(TestCase):
|
|||
self.assertEqual(0, p.previous_page_number())
|
||||
self.assertEqual(1, p.start_index())
|
||||
self.assertEqual(5, p.end_index())
|
||||
|
||||
|
||||
def test_paginate_misc_classes(self):
|
||||
# Paginator can be passed other objects with a count() method.
|
||||
paginator = Paginator(CountContainer(), 10)
|
||||
self.assertEqual(42, paginator.count)
|
||||
self.assertEqual(5, paginator.num_pages)
|
||||
self.assertEqual([1, 2, 3, 4, 5], paginator.page_range)
|
||||
|
||||
|
||||
# Paginator can be passed other objects that implement __len__.
|
||||
paginator = Paginator(LenContainer(), 10)
|
||||
self.assertEqual(42, paginator.count)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
|
||||
## Basic tests
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
from django.utils import unittest
|
||||
|
||||
from models import (Author, Book, Reader, Qualification, Teacher, Department,
|
||||
TaggedItem, Bookmark, AuthorAddress, FavoriteAuthors,
|
||||
AuthorWithAge, BookWithYear, Person, House, Room,
|
||||
Employee)
|
||||
from .models import (Author, Book, Reader, Qualification, Teacher, Department,
|
||||
TaggedItem, Bookmark, AuthorAddress, FavoriteAuthors, AuthorWithAge,
|
||||
BookWithYear, Person, House, Room, Employee)
|
||||
|
||||
|
||||
class PrefetchRelatedTests(TestCase):
|
||||
|
|
|
@ -6,6 +6,7 @@ Use properties on models just like on any other Python object.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Person(models.Model):
|
||||
first_name = models.CharField(max_length=30)
|
||||
last_name = models.CharField(max_length=30)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import with_statement, absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
from models import Person
|
||||
|
||||
from .models import Person
|
||||
|
||||
|
||||
class PropertyTests(TestCase):
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
# TODO: why can't I make this ..app2
|
||||
from app2.models import NiceModel
|
||||
|
||||
|
||||
class ProxyModel(NiceModel):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class NiceModel(models.Model):
|
||||
pass
|
||||
|
|
|
@ -6,6 +6,8 @@ for the proxied model (as described in #12286). This test creates two dummy
|
|||
apps and calls syncdb, then verifies that the table has been created.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -15,6 +17,7 @@ from django.db.models.loading import load_app
|
|||
from django.test import TransactionTestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
|
||||
# @override_settings(INSTALLED_APPS=('app1', 'app2'))
|
||||
class ProxyModelInheritanceTests(TransactionTestCase):
|
||||
|
||||
|
@ -28,9 +31,8 @@ class ProxyModelInheritanceTests(TransactionTestCase):
|
|||
|
||||
def test_table_exists(self):
|
||||
call_command('syncdb', verbosity=0)
|
||||
global ProxyModel, NiceModel
|
||||
from app1.models import ProxyModel
|
||||
from app2.models import NiceModel
|
||||
from .app1.models import ProxyModel
|
||||
from .app2.models import NiceModel
|
||||
self.assertEqual(NiceModel.objects.all().count(), 0)
|
||||
self.assertEqual(ProxyModel.objects.all().count(), 0)
|
||||
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
from django.test import TestCase
|
||||
from django.db import models, DEFAULT_DB_ALIAS
|
||||
from django.db.models import signals
|
||||
from django.core import management
|
||||
from django.core.exceptions import FieldError
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core import management
|
||||
from django.core.exceptions import FieldError
|
||||
from django.db import models, DEFAULT_DB_ALIAS
|
||||
from django.db.models import signals
|
||||
from django.test import TestCase
|
||||
|
||||
from models import MyPerson, Person, StatusPerson, LowerStatusPerson
|
||||
from models import MyPersonProxy, Abstract, OtherPerson, User, UserProxy
|
||||
from models import UserProxyProxy, Country, State, StateProxy, TrackerUser
|
||||
from models import BaseUser, Bug, ProxyTrackerUser, Improvement, ProxyProxyBug
|
||||
from models import ProxyBug, ProxyImprovement
|
||||
|
||||
from .models import (MyPerson, Person, StatusPerson, LowerStatusPerson,
|
||||
MyPersonProxy, Abstract, OtherPerson, User, UserProxy, UserProxyProxy,
|
||||
Country, State, StateProxy, TrackerUser, BaseUser, Bug, ProxyTrackerUser,
|
||||
Improvement, ProxyProxyBug, ProxyBug, ProxyImprovement)
|
||||
|
||||
class ProxyModelTests(TestCase):
|
||||
def test_same_manager_queries(self):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Author(models.Model):
|
||||
first_name = models.CharField(max_length=255)
|
||||
last_name = models.CharField(max_length=255)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import date
|
||||
|
||||
from django.db.models.sql.query import InvalidQuery
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Author, Book, Coffee, Reviewer, FriendlyAuthor
|
||||
from .models import Author, Book, Coffee, Reviewer, FriendlyAuthor
|
||||
|
||||
|
||||
class RawQueryTests(TestCase):
|
||||
|
|
|
@ -9,6 +9,7 @@ reserved-name usage.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Thing(models.Model):
|
||||
when = models.CharField(max_length=1, primary_key=True)
|
||||
join = models.CharField(max_length=1)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Thing
|
||||
from .models import Thing
|
||||
|
||||
|
||||
class ReservedNameTests(TestCase):
|
||||
def generate(self):
|
||||
|
|
|
@ -6,6 +6,7 @@ This demonstrates the reverse lookup features of the database API.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class User(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
from django.test import TestCase
|
||||
from django.core.exceptions import FieldError
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.core.exceptions import FieldError
|
||||
from django.test import TestCase
|
||||
|
||||
from .models import User, Poll, Choice
|
||||
|
||||
from models import User, Poll, Choice
|
||||
|
||||
class ReverseLookupTests(TestCase):
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Person
|
||||
from .models import Person
|
||||
|
||||
|
||||
class SaveDeleteHookTests(TestCase):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Person(models.Model):
|
||||
name = models.CharField(max_length=30)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import transaction, connection
|
||||
from django.db.utils import ConnectionHandler, DEFAULT_DB_ALIAS, DatabaseError
|
||||
|
@ -8,7 +10,7 @@ from django.test import (TransactionTestCase, skipIfDBFeature,
|
|||
skipUnlessDBFeature)
|
||||
from django.utils import unittest
|
||||
|
||||
from models import Person
|
||||
from .models import Person
|
||||
|
||||
# Some tests require threading, which might not be available. So create a
|
||||
# skip-test decorator for those test functions.
|
||||
|
@ -18,6 +20,7 @@ except ImportError:
|
|||
threading = None
|
||||
requires_threading = unittest.skipUnless(threading, 'requires threading')
|
||||
|
||||
|
||||
class SelectForUpdateTests(TransactionTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Domain, Kingdom, Phylum, Klass, Order, Family, Genus, Species
|
||||
from .models import Domain, Kingdom, Phylum, Klass, Order, Family, Genus, Species
|
||||
|
||||
class SelectRelatedTests(TestCase):
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# This is necessary in Python 2.5 to enable the with statement, in 2.6
|
||||
# and up it is no longer necessary.
|
||||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
from datetime import datetime
|
||||
from StringIO import StringIO
|
||||
from xml.dom import minidom
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import serializers
|
||||
|
@ -13,8 +13,9 @@ from django.db import transaction, connection
|
|||
from django.test import TestCase, TransactionTestCase, Approximate
|
||||
from django.utils import simplejson, unittest
|
||||
|
||||
from models import (Category, Author, Article, AuthorProfile,
|
||||
Actor, Movie, Score, Player, Team)
|
||||
from .models import (Category, Author, Article, AuthorProfile, Actor, Movie,
|
||||
Score, Player, Team)
|
||||
|
||||
|
||||
class SerializerRegistrationTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.db.models import signals
|
||||
from django.dispatch import receiver
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Person, Car
|
||||
from .models import Person, Car
|
||||
|
||||
|
||||
# #8285: signals can be any callable
|
||||
|
|
|
@ -16,6 +16,7 @@ if you prefer. You must be careful to encode the results correctly, though.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
headline = models.CharField(max_length=100)
|
||||
pub_date = models.DateTimeField()
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue