mirror of https://github.com/django/django.git
Convert much of the regression tests to use absolute imports. There's still work to be done though.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16976 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d5a45d79fe
commit
d362c1546f
|
@ -1,9 +1,12 @@
|
|||
from django.core.paginator import Paginator
|
||||
from django.contrib import admin
|
||||
from __future__ import absolute_import
|
||||
|
||||
from models import (Child, Parent, Genre, Band, Musician, Group, Quartet,
|
||||
from django.contrib import admin
|
||||
from django.core.paginator import Paginator
|
||||
|
||||
from .models import (Child, Parent, Genre, Band, Musician, Group, Quartet,
|
||||
Membership, ChordsMusician, ChordsBand, Invitation)
|
||||
|
||||
|
||||
site = admin.AdminSite(name="admin")
|
||||
|
||||
class CustomPaginator(Paginator):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Parent(models.Model):
|
||||
name = models.CharField(max_length=128)
|
||||
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.options import IncorrectLookupParameters
|
||||
from django.contrib.admin.views.main import ChangeList, SEARCH_VAR, ALL_VAR
|
||||
from django.contrib.auth.models import User
|
||||
from django.template import Context, Template
|
||||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from models import (Child, Parent, Genre, Band, Musician, Group, Quartet,
|
||||
Membership, ChordsMusician, ChordsBand, Invitation)
|
||||
|
||||
from admin import (ChildAdmin, QuartetAdmin, BandAdmin, ChordsBandAdmin,
|
||||
from .admin import (ChildAdmin, QuartetAdmin, BandAdmin, ChordsBandAdmin,
|
||||
GroupAdmin, ParentAdmin, DynamicListDisplayChildAdmin, CustomPaginationAdmin,
|
||||
FilteredChildAdmin, CustomPaginator, site as custom_site)
|
||||
from .models import (Child, Parent, Genre, Band, Musician, Group, Quartet,
|
||||
Membership, ChordsMusician, ChordsBand, Invitation)
|
||||
|
||||
|
||||
class ChangeListTests(TestCase):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django.conf.urls import patterns, include
|
||||
|
||||
import admin
|
||||
from . import admin
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.template.response import TemplateResponse
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Action
|
||||
from .models import Action
|
||||
|
||||
|
||||
class AdminCustomUrlsTest(TestCase):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Book(models.Model):
|
||||
title = models.CharField(max_length=50)
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from django.contrib.admin import (site, ModelAdmin, SimpleListFilter,
|
||||
BooleanFieldListFilter)
|
||||
from django.contrib.admin.options import IncorrectLookupParameters
|
||||
from django.contrib.admin.views.main import ChangeList
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.test import TestCase, RequestFactory
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.admin.views.main import ChangeList
|
||||
from django.contrib.admin import (site, ModelAdmin, SimpleListFilter,
|
||||
BooleanFieldListFilter)
|
||||
|
||||
from models import Book
|
||||
from .models import Book
|
||||
|
||||
|
||||
def select_by(dictlist, key, value):
|
||||
return [x for x in dictlist if x[key] == value][0]
|
||||
|
||||
|
||||
class DecadeListFilter(SimpleListFilter):
|
||||
|
||||
def lookups(self, request, model_admin):
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.admin.helpers import InlineAdminForm
|
||||
from django.contrib.auth.models import User, Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
# local test models
|
||||
from models import (Holder, Inner, Holder2, Inner2, Holder3,
|
||||
Inner3, Person, OutfitItem, Fashionista, Teacher, Parent, Child,
|
||||
Author, Book)
|
||||
from admin import InnerInline
|
||||
from .admin import InnerInline
|
||||
from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person,
|
||||
OutfitItem, Fashionista, Teacher, Parent, Child, Author, Book)
|
||||
|
||||
|
||||
class TestInline(TestCase):
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import patterns, include
|
||||
|
||||
import admin
|
||||
from . import admin
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# coding: utf-8
|
||||
from django.db import models
|
||||
from django.contrib import admin
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Band(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from django.test import TestCase, RequestFactory
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.admin.options import ModelAdmin
|
||||
from __future__ import absolute_import
|
||||
|
||||
from models import Band, Song, SongInlineDefaultOrdering, SongInlineNewOrdering, DynOrderingBandAdmin
|
||||
from django.test import TestCase, RequestFactory
|
||||
from django.contrib.admin.options import ModelAdmin
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from .models import (Band, Song, SongInlineDefaultOrdering,
|
||||
SongInlineNewOrdering, DynOrderingBandAdmin)
|
||||
|
||||
|
||||
class MockRequest(object):
|
||||
|
|
|
@ -4,6 +4,7 @@ Tests for various ways of registering models with the admin site.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Person(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from django.test import TestCase
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.contrib import admin
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib import admin
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.test import TestCase
|
||||
|
||||
from .models import Person, Place, Location
|
||||
|
||||
from models import Person, Place, Location
|
||||
|
||||
class NameAdmin(admin.ModelAdmin):
|
||||
list_display = ['name']
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.contrib.comments.models import Comment
|
||||
from django.db import models
|
||||
from django.contrib.comments.models import Comment
|
||||
|
||||
|
||||
# Regression for #13368. This is an example of a model
|
||||
# that imports a class that has an abstract base class.
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib import admin
|
||||
from admin_scripts.complex_app.models.foo import Foo
|
||||
|
||||
from ..models.foo import Foo
|
||||
|
||||
|
||||
admin.site.register(Foo)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from admin_scripts.complex_app.models.bar import Bar
|
||||
from admin_scripts.complex_app.models.foo import Foo
|
||||
from .bar import Bar
|
||||
from .foo import Foo
|
||||
|
||||
__all__ = ['Foo', 'Bar']
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
|
||||
from admin_scripts.complex_app.admin import foo
|
||||
from ..admin import foo
|
||||
|
||||
|
||||
class Bar(models.Model):
|
||||
name = models.CharField(max_length=5)
|
||||
class Meta:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Foo(models.Model):
|
||||
name = models.CharField(max_length=5)
|
||||
class Meta:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.core.management.base import AppCommand
|
||||
|
||||
|
||||
class Command(AppCommand):
|
||||
help = 'Test Application-based commands'
|
||||
requires_model_validation = False
|
||||
|
@ -7,4 +8,4 @@ class Command(AppCommand):
|
|||
|
||||
def handle_app(self, app, **options):
|
||||
print 'EXECUTE:AppCommand app=%s, options=%s' % (app, sorted(options.items()))
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--option_a','-a', action='store', dest='option_a', default='1'),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.core.management.base import LabelCommand
|
||||
|
||||
|
||||
class Command(LabelCommand):
|
||||
help = "Test Label-based commands"
|
||||
requires_model_validation = False
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.core.management.base import NoArgsCommand
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
help = "Test No-args commands"
|
||||
requires_model_validation = False
|
||||
|
|
|
@ -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()
|
||||
|
@ -9,4 +10,3 @@ class Article(models.Model):
|
|||
|
||||
class Meta:
|
||||
ordering = ('-pub_date', 'headline')
|
||||
|
|
@ -1 +1,3 @@
|
|||
from admin_scripts.complex_app.models.bar import Bar
|
||||
from __future__ import absolute_import
|
||||
|
||||
from ..complex_app.models.bar import Bar
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
"""
|
||||
A simple Article model for testing
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.util import display_for_field, label_for_field, lookup_field
|
||||
from django.contrib.admin.util import NestedObjects
|
||||
from django.contrib.admin.util import (display_for_field, label_for_field,
|
||||
lookup_field, NestedObjects)
|
||||
from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
|
||||
from django.contrib.sites.models import Site
|
||||
from django.db import models, DEFAULT_DB_ALIAS
|
||||
|
@ -11,7 +13,7 @@ from django.test import TestCase
|
|||
from django.utils import unittest
|
||||
from django.utils.formats import localize
|
||||
|
||||
from models import Article, Count, Event, Location
|
||||
from .models import Article, Count, Event, Location
|
||||
|
||||
|
||||
class NestedObjectsTests(TestCase):
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.validation import validate, validate_inline
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.test import TestCase
|
||||
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.validation import validate, validate_inline
|
||||
from .models import Song, Book, Album, TwoAlbumFKAndAnE, State, City
|
||||
|
||||
from models import Song, Book, Album, TwoAlbumFKAndAnE, State, City
|
||||
|
||||
class SongForm(forms.ModelForm):
|
||||
pass
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.views.main import ChangeList
|
||||
from django.forms.models import BaseModelFormSet
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.core.mail import EmailMessage
|
||||
from django.db import models
|
||||
from django.forms.models import BaseModelFormSet
|
||||
|
||||
from models import *
|
||||
from .models import (Article, Chapter, Account, Media, Child, Parent, Picture,
|
||||
Widget, DooHickey, Grommet, Whatsit, FancyDoodad, Category, Link,
|
||||
PrePopulatedPost, PrePopulatedSubPost, CustomArticle, Section,
|
||||
ModelWithStringPrimaryKey, Color, Thing, Actor, Inquisition, Sketch, Person,
|
||||
Persona, Subscriber, ExternalSubscriber, OldSubscriber, Vodcast, EmptyModel,
|
||||
Fabric, Gallery, Language, Recommendation, Recommender, Collector, Post,
|
||||
Gadget, Villain, SuperVillain, Plot, PlotDetails, CyclicOne, CyclicTwo,
|
||||
WorkHour, Reservation, FoodDelivery, RowLevelChangePermissionModel, Paper,
|
||||
CoverLetter, Story, OtherStory, Book, Promo, ChapterXtra1, Pizza, Topping,
|
||||
Album, Question, Answer, ComplexSortedPerson)
|
||||
|
||||
|
||||
def callable_year(dt_value):
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
"""
|
||||
A second, custom AdminSite -- see tests.CustomAdminSiteTests.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import patterns
|
||||
from django.contrib import admin
|
||||
from django.http import HttpResponse
|
||||
|
||||
import models, forms, admin as base_admin
|
||||
from . import models, forms, admin as base_admin
|
||||
|
||||
|
||||
class Admin2(admin.AdminSite):
|
||||
login_form = forms.CustomAdminAuthenticationForm
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django import forms
|
||||
from django.contrib.admin.forms import AdminAuthenticationForm
|
||||
|
||||
|
||||
class CustomAdminAuthenticationForm(AdminAuthenticationForm):
|
||||
|
||||
def clean_username(self):
|
||||
|
|
|
@ -3,12 +3,12 @@ import datetime
|
|||
import tempfile
|
||||
import os
|
||||
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.db import models
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Section(models.Model):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# coding: utf-8
|
||||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
import re
|
||||
import datetime
|
||||
|
@ -11,39 +11,37 @@ from django.core.exceptions import SuspiciousOperation
|
|||
from django.core.files import temp as tempfile
|
||||
from django.core.urlresolvers import reverse
|
||||
# Register auth models with the admin.
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME, admin
|
||||
from django.contrib.auth.models import Group, User, Permission, UNUSABLE_PASSWORD
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
|
||||
from django.contrib.admin.models import LogEntry, DELETION
|
||||
from django.contrib.admin.sites import LOGIN_FORM_KEY
|
||||
from django.contrib.admin.util import quote
|
||||
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
|
||||
from django.contrib.admin.views.main import IS_POPUP_VAR
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME, admin
|
||||
from django.contrib.auth.models import Group, User, Permission, UNUSABLE_PASSWORD
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.forms.util import ErrorList
|
||||
import django.template.context
|
||||
from django.template import context as context_module
|
||||
from django.template.response import TemplateResponse
|
||||
from django.test import TestCase
|
||||
from django.utils import formats, translation
|
||||
from django.utils import formats, translation, unittest
|
||||
from django.utils.cache import get_max_age
|
||||
from django.utils.encoding import iri_to_uri
|
||||
from django.utils.html import escape
|
||||
from django.utils.http import urlencode
|
||||
from django.utils import unittest
|
||||
|
||||
# local test models
|
||||
from models import (Article, BarAccount, CustomArticle, EmptyModel,
|
||||
FooAccount, Gallery, ModelWithStringPrimaryKey,
|
||||
Person, Persona, Picture, Podcast, Section, Subscriber, Vodcast,
|
||||
Language, Collector, Widget, Grommet, DooHickey, FancyDoodad, Whatsit,
|
||||
Category, Post, Plot, FunkyTag, Chapter, Book, Promo, WorkHour, Employee,
|
||||
Question, Answer, Inquisition, Actor, FoodDelivery,
|
||||
RowLevelChangePermissionModel, Paper, CoverLetter, Story, OtherStory,
|
||||
ComplexSortedPerson, Parent, Child)
|
||||
from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount,
|
||||
Gallery, ModelWithStringPrimaryKey, Person, Persona, Picture, Podcast,
|
||||
Section, Subscriber, Vodcast, Language, Collector, Widget, Grommet,
|
||||
DooHickey, FancyDoodad, Whatsit, Category, Post, Plot, FunkyTag, Chapter,
|
||||
Book, Promo, WorkHour, Employee, Question, Answer, Inquisition, Actor,
|
||||
FoodDelivery, RowLevelChangePermissionModel, Paper, CoverLetter, Story,
|
||||
OtherStory, ComplexSortedPerson, Parent, Child)
|
||||
|
||||
|
||||
ERROR_MESSAGE = "Please enter the correct username and password \
|
||||
for a staff account. Note that both fields are case-sensitive."
|
||||
|
||||
|
||||
class AdminViewBasicTest(TestCase):
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml',
|
||||
'admin-views-fabrics.xml', 'admin-views-books.xml']
|
||||
|
@ -3073,7 +3071,7 @@ class ValidXHTMLTests(TestCase):
|
|||
cp.remove('django.core.context_processors.i18n')
|
||||
settings.TEMPLATE_CONTEXT_PROCESSORS = tuple(cp)
|
||||
# Force re-evaluation of the contex processor list
|
||||
django.template.context._standard_context_processors = None
|
||||
context_module._standard_context_processors = None
|
||||
self.client.login(username='super', password='secret')
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -3081,7 +3079,7 @@ class ValidXHTMLTests(TestCase):
|
|||
if self._context_processors is not None:
|
||||
settings.TEMPLATE_CONTEXT_PROCESSORS = self._context_processors
|
||||
# Force re-evaluation of the contex processor list
|
||||
django.template.context._standard_context_processors = None
|
||||
context_module._standard_context_processors = None
|
||||
settings.USE_I18N = self._use_i18n
|
||||
|
||||
def testLangNamePresent(self):
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import patterns, include
|
||||
import views
|
||||
import customadmin
|
||||
import admin
|
||||
|
||||
from . import views, customadmin, admin
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^test_admin/admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# encoding: utf-8
|
||||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
@ -15,8 +15,9 @@ from django.utils import translation
|
|||
from django.utils.html import conditional_escape
|
||||
from django.utils.unittest import TestCase
|
||||
|
||||
import models
|
||||
from widgetadmin import site as widget_admin_site
|
||||
from . import models
|
||||
from .widgetadmin import site as widget_admin_site
|
||||
|
||||
|
||||
admin_media_prefix = lambda: {
|
||||
'ADMIN_MEDIA_PREFIX': "%sadmin/" % settings.STATIC_URL,
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import patterns, include
|
||||
import widgetadmin
|
||||
|
||||
from . import widgetadmin
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^', include(widgetadmin.site.urls)),
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"""
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
import models
|
||||
from . import models
|
||||
|
||||
|
||||
class WidgetAdmin(admin.AdminSite):
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
import pickle
|
||||
from decimal import Decimal
|
||||
|
@ -7,7 +9,7 @@ from django.core.exceptions import FieldError
|
|||
from django.db.models import Count, Max, Avg, Sum, StdDev, Variance, F, Q
|
||||
from django.test import TestCase, Approximate, skipUnlessDBFeature
|
||||
|
||||
from models import Author, Book, Publisher, Clues, Entries, HardbackBook
|
||||
from .models import Author, Book, Publisher, Clues, Entries, HardbackBook
|
||||
|
||||
|
||||
class AggregationTests(TestCase):
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import copy
|
||||
import os
|
||||
import sys
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from django.db import connection
|
||||
from django.db import models, connection
|
||||
|
||||
|
||||
class Square(models.Model):
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Unit and doctests for specific database backends.
|
||||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.color import no_style
|
||||
from django.db import backend, connection, connections, DEFAULT_DB_ALIAS, IntegrityError, transaction
|
||||
from django.db import (backend, connection, connections, DEFAULT_DB_ALIAS,
|
||||
IntegrityError, transaction)
|
||||
from django.db.backends.signals import connection_created
|
||||
from django.db.backends.postgresql_psycopg2 import version as pg_version
|
||||
from django.test import TestCase, skipUnlessDBFeature, TransactionTestCase
|
||||
from django.utils import unittest
|
||||
|
||||
from regressiontests.backends import models
|
||||
from . import models
|
||||
|
||||
|
||||
class OracleChecks(unittest.TestCase):
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ from django.conf import settings
|
|||
from django.core.management import ManagementUtility
|
||||
from django.utils import unittest
|
||||
|
||||
|
||||
class BashCompletionTests(unittest.TestCase):
|
||||
"""
|
||||
Testing the Python level bash completion code.
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import tempfile
|
||||
|
||||
from django.db import models
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
|
||||
|
||||
temp_storage_dir = tempfile.mkdtemp()
|
||||
temp_storage = FileSystemStorage(temp_storage_dir)
|
||||
|
||||
|
|
|
@ -4,13 +4,16 @@ gets called *again* for each FileField. This test will fail if calling a
|
|||
ModelForm's save() method causes Model.save() to be called more than once.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.utils import unittest
|
||||
|
||||
from regressiontests.bug639.models import Photo, PhotoForm, temp_storage_dir
|
||||
from .models import Photo, PhotoForm, temp_storage_dir
|
||||
|
||||
|
||||
class Bug639Test(unittest.TestCase):
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from models import Story
|
||||
from .models import Story
|
||||
|
||||
|
||||
admin.site.register(Story)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Story(models.Model):
|
||||
title = models.CharField(max_length=10)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
from django.contrib import admin
|
||||
from django.utils.unittest import TestCase
|
||||
|
||||
|
@ -9,20 +11,12 @@ class Bug8245Test(TestCase):
|
|||
"""
|
||||
def test_bug_8245(self):
|
||||
# The first time autodiscover is called, we should get our real error.
|
||||
try:
|
||||
with self.assertRaises(Exception) as cm:
|
||||
admin.autodiscover()
|
||||
except Exception, e:
|
||||
self.assertEqual(str(e), "Bad admin module")
|
||||
else:
|
||||
self.fail(
|
||||
'autodiscover should have raised a "Bad admin module" error.')
|
||||
self.assertEqual(str(cm.exception), "Bad admin module")
|
||||
|
||||
# Calling autodiscover again should raise the very same error it did
|
||||
# the first time, not an AlreadyRegistered error.
|
||||
try:
|
||||
with self.assertRaises(Exception) as cm:
|
||||
admin.autodiscover()
|
||||
except Exception, e:
|
||||
self.assertEqual(str(e), "Bad admin module")
|
||||
else:
|
||||
self.fail(
|
||||
'autodiscover should have raised a "Bad admin module" error.')
|
||||
self.assertEqual(str(cm.exception), "Bad admin module")
|
|
@ -1,10 +1,10 @@
|
|||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
from operator import attrgetter
|
||||
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
|
||||
from models import Country, Restaurant, Pizzeria, State
|
||||
from .models import Country, Restaurant, Pizzeria, State
|
||||
|
||||
|
||||
class BulkCreateTests(TestCase):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.core.cache.backends.locmem import LocMemCache
|
||||
|
||||
|
||||
class LiberalKeyValidationMixin(object):
|
||||
def validate_key(self, key):
|
||||
pass
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from django.db import models
|
||||
from datetime import datetime
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
def expensive_calculation():
|
||||
expensive_calculation.num_runs += 1
|
||||
return datetime.now()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Unit tests for cache framework
|
||||
# Uses whatever cache backend is set in the test settings file.
|
||||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
|
@ -29,7 +29,7 @@ from django.utils.cache import (patch_vary_headers, get_cache_key,
|
|||
learn_cache_key, patch_cache_control, patch_response_headers)
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
from regressiontests.cache.models import Poll, expensive_calculation
|
||||
from .models import Poll, expensive_calculation
|
||||
|
||||
# functions/classes for complex data type tests
|
||||
def f():
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django import forms
|
||||
|
||||
|
||||
class CustomCommentForm(forms.Form):
|
||||
pass
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class CustomComment(models.Model):
|
||||
pass
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.http import HttpResponse
|
||||
|
||||
|
||||
def custom_submit_comment(request):
|
||||
return HttpResponse("Hello from the custom submit comment view.")
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ more information.
|
|||
"""
|
||||
|
||||
from django.db import models
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class Author(models.Model):
|
||||
first_name = models.CharField(max_length=30)
|
||||
|
@ -31,4 +31,3 @@ class Entry(models.Model):
|
|||
|
||||
class Book(models.Model):
|
||||
dewey_decimal = models.DecimalField(primary_key=True, decimal_places=2, max_digits=5)
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.comments.forms import CommentForm
|
||||
from django.contrib.comments.models import Comment
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.sites.models import Site
|
||||
from django.test import TestCase
|
||||
from regressiontests.comment_tests.models import Article, Author
|
||||
|
||||
from ..models import Article, Author
|
||||
|
||||
# Shortcut
|
||||
CT = ContentType.objects.get_for_model
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import comments
|
||||
from django.contrib.comments.models import Comment
|
||||
from django.contrib.comments.forms import CommentForm
|
||||
from regressiontests.comment_tests.tests import CommentTestCase
|
||||
|
||||
from . import CommentTestCase
|
||||
|
||||
|
||||
class CommentAppAPITests(CommentTestCase):
|
||||
"""Tests for the "comment app" API"""
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import time
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.comments.forms import CommentForm
|
||||
from django.contrib.comments.models import Comment
|
||||
|
||||
from regressiontests.comment_tests.models import Article
|
||||
from regressiontests.comment_tests.tests import CommentTestCase
|
||||
from . import CommentTestCase
|
||||
from ..models import Article
|
||||
|
||||
|
||||
class CommentFormTests(CommentTestCase):
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
from django.core import mail
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.comments.models import Comment
|
||||
from django.contrib.comments.moderation import (moderator, CommentModerator,
|
||||
AlreadyModerated)
|
||||
AlreadyModerated)
|
||||
from django.core import mail
|
||||
|
||||
from . import CommentTestCase
|
||||
from ..models import Entry
|
||||
|
||||
from regressiontests.comment_tests.models import Entry
|
||||
from regressiontests.comment_tests.tests import CommentTestCase
|
||||
|
||||
class EntryModerator1(CommentModerator):
|
||||
email_notification = True
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.comments import signals
|
||||
from django.contrib.comments.models import Comment
|
||||
from regressiontests.comment_tests.models import Article, Book
|
||||
from regressiontests.comment_tests.tests import CommentTestCase
|
||||
|
||||
from . import CommentTestCase
|
||||
from ..models import Article, Book
|
||||
|
||||
|
||||
post_redirect_re = re.compile(r'^http://testserver/posted/\?c=(?P<pk>\d+$)')
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from regressiontests.comment_tests.tests import CommentTestCase
|
||||
from __future__ import absolute_import
|
||||
|
||||
from . import CommentTestCase
|
||||
|
||||
|
||||
class CommentFeedTests(CommentTestCase):
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.comments.models import Comment
|
||||
|
||||
from regressiontests.comment_tests.models import Author, Article
|
||||
from regressiontests.comment_tests.tests import CommentTestCase
|
||||
from . import CommentTestCase
|
||||
from ..models import Author, Article
|
||||
|
||||
|
||||
class CommentModelTests(CommentTestCase):
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.auth.models import User, Permission
|
||||
from django.contrib.comments import signals
|
||||
from django.contrib.comments.models import Comment, CommentFlag
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from regressiontests.comment_tests.tests import CommentTestCase
|
||||
from . import CommentTestCase
|
||||
|
||||
|
||||
class FlagViewTests(CommentTestCase):
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
from __future__ import with_statement
|
||||
from __future__ import with_statement, absolute_import
|
||||
|
||||
from django.contrib.comments.forms import CommentForm
|
||||
from django.contrib.comments.models import Comment
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.template import Template, Context
|
||||
from regressiontests.comment_tests.models import Article, Author
|
||||
from regressiontests.comment_tests.tests import CommentTestCase
|
||||
|
||||
from ..models import Article, Author
|
||||
from . import CommentTestCase
|
||||
|
||||
|
||||
class CommentTemplateTagTests(CommentTestCase):
|
||||
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import patterns, url
|
||||
from django.contrib.comments.feeds import LatestCommentFeed
|
||||
|
||||
from .custom_comments import views
|
||||
|
||||
|
||||
feeds = {
|
||||
'comments': LatestCommentFeed,
|
||||
}
|
||||
|
||||
urlpatterns = patterns('regressiontests.comment_tests.custom_comments.views',
|
||||
url(r'^post/$', 'custom_submit_comment'),
|
||||
url(r'^flag/(\d+)/$', 'custom_flag_comment'),
|
||||
url(r'^delete/(\d+)/$', 'custom_delete_comment'),
|
||||
url(r'^approve/(\d+)/$', 'custom_approve_comment'),
|
||||
urlpatterns = patterns('',
|
||||
url(r'^post/$', views.custom_submit_comment),
|
||||
url(r'^flag/(\d+)/$', views.custom_flag_comment),
|
||||
url(r'^delete/(\d+)/$', views.custom_delete_comment),
|
||||
url(r'^approve/(\d+)/$', views.custom_approve_comment),
|
||||
)
|
||||
|
||||
urlpatterns += patterns('',
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.test import TestCase
|
|||
from django.utils import unittest
|
||||
from django.utils.http import parse_etags, quote_etag, parse_http_date
|
||||
|
||||
|
||||
FULL_RESPONSE = 'Test conditional get response'
|
||||
LAST_MODIFIED = datetime(2007, 10, 21, 23, 21, 47)
|
||||
LAST_MODIFIED_STR = 'Sun, 21 Oct 2007 23:21:47 GMT'
|
||||
|
@ -14,7 +15,6 @@ EXPIRED_LAST_MODIFIED_STR = 'Sat, 20 Oct 2007 23:21:47 GMT'
|
|||
ETAG = 'b4246ffc4f62314ca13147c9d4f76974'
|
||||
EXPIRED_ETAG = '7fae4cd4b0f81e7d2914700043aa8ed6'
|
||||
|
||||
|
||||
class ConditionalGet(TestCase):
|
||||
urls = 'regressiontests.conditional_processing.urls'
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.conf.urls import patterns
|
||||
import views
|
||||
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
('^condition/$', views.index),
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.views.decorators.http import condition, etag, last_modified
|
||||
from django.http import HttpResponse
|
||||
|
||||
from models import FULL_RESPONSE, LAST_MODIFIED, ETAG
|
||||
from .models import FULL_RESPONSE, LAST_MODIFIED, ETAG
|
||||
|
||||
|
||||
def index(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import patterns, url
|
||||
|
||||
import views
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import with_statement
|
||||
|
||||
from django.test import TestCase
|
||||
from django.conf import settings
|
||||
from django.core.context_processors import csrf
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.middleware.csrf import CsrfViewMiddleware
|
||||
from django.views.decorators.csrf import csrf_exempt, requires_csrf_token, ensure_csrf_cookie
|
||||
from django.core.context_processors import csrf
|
||||
from django.conf import settings
|
||||
from django.template import RequestContext, Template
|
||||
from django.test import TestCase
|
||||
from django.views.decorators.csrf import csrf_exempt, requires_csrf_token, ensure_csrf_cookie
|
||||
|
||||
|
||||
# Response/views used for CsrfResponseMiddleware and CsrfViewMiddleware tests
|
||||
def post_form_response():
|
||||
|
|
|
@ -8,6 +8,7 @@ table creation or queries.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
Article_ID = models.AutoField(primary_key=True, db_column='Article ID')
|
||||
headline = models.CharField(max_length=100)
|
||||
|
|
|
@ -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 Author, Article
|
||||
|
||||
from models import Author, Article
|
||||
|
||||
def pks(objects):
|
||||
""" Return pks to be able to compare lists"""
|
||||
|
|
|
@ -4,6 +4,7 @@ Regression tests for custom manager classes.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class RestrictedManager(models.Manager):
|
||||
"""
|
||||
A manager that filters out non-public instances.
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import RelatedModel, RestrictedModel, OneToOneRestrictedModel
|
||||
from .models import RelatedModel, RestrictedModel, OneToOneRestrictedModel
|
||||
|
||||
|
||||
class CustomManagersRegressTestCase(TestCase):
|
||||
def test_filtered_default_manager(self):
|
||||
|
|
|
@ -5,6 +5,7 @@ types, which in the past were problematic for some database backends.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Donut(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
is_frosted = models.BooleanField(default=False)
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from django.test import TestCase, skipIfDBFeature
|
||||
from django.utils import tzinfo
|
||||
|
||||
from models import Donut, RumBaba
|
||||
from .models import Donut, RumBaba
|
||||
|
||||
|
||||
class DataTypesTestCase(TestCase):
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Article, Comment, Category
|
||||
from .models import Article, Comment, Category
|
||||
|
||||
|
||||
class DatesTests(TestCase):
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
from functools import wraps
|
||||
import warnings
|
||||
from functools import wraps
|
||||
|
||||
from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
|
||||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
|
||||
from django.http import HttpResponse, HttpRequest, HttpResponseNotAllowed
|
||||
from django.middleware.clickjacking import XFrameOptionsMiddleware
|
||||
from django.test.utils import get_warnings_state, restore_warnings_state
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.functional import allow_lazy, lazy, memoize
|
||||
from django.utils.unittest import TestCase
|
||||
from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe
|
||||
from django.views.decorators.vary import vary_on_headers, vary_on_cookie
|
||||
from django.views.decorators.cache import cache_page, never_cache, cache_control
|
||||
from django.views.decorators.clickjacking import xframe_options_deny, xframe_options_sameorigin, xframe_options_exempt
|
||||
from django.middleware.clickjacking import XFrameOptionsMiddleware
|
||||
from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe
|
||||
from django.views.decorators.vary import vary_on_headers, vary_on_cookie
|
||||
|
||||
|
||||
def fully_decorated(request):
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import with_statement
|
||||
|
||||
import datetime
|
||||
|
||||
from django.template.defaultfilters import *
|
||||
from django.test import TestCase
|
||||
from django.utils import unittest, translation
|
||||
|
||||
from django.template.defaultfilters import *
|
||||
|
||||
class DefaultFiltersTests(TestCase):
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ Regression tests for defer() / only() behavior.
|
|||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Item(models.Model):
|
||||
name = models.CharField(max_length=15)
|
||||
text = models.TextField(default="xyzzy")
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from operator import attrgetter
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
@ -6,8 +8,8 @@ from django.db.models import Count
|
|||
from django.db.models.loading import cache
|
||||
from django.test import TestCase
|
||||
|
||||
from models import (ResolveThis, Item, RelatedItem, Child, Leaf, Proxy,
|
||||
SimpleItem, Feature)
|
||||
from .models import (ResolveThis, Item, RelatedItem, Child, Leaf, Proxy,
|
||||
SimpleItem, Feature)
|
||||
|
||||
|
||||
class DeferRegressionTest(TestCase):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.db import models
|
||||
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Award(models.Model):
|
||||
name = models.CharField(max_length=25)
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import backend, transaction, DEFAULT_DB_ALIAS
|
||||
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
|
||||
|
||||
from models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
|
||||
PlayedWithNote, Email, Researcher, Food, Eaten,
|
||||
Policy, Version, Location, Item)
|
||||
from .models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
|
||||
PlayedWithNote, Email, Researcher, Food, Eaten, Policy, Version, Location,
|
||||
Item)
|
||||
|
||||
|
||||
# Can't run this test under SQLite, because you can't
|
||||
|
|
|
@ -2,5 +2,7 @@
|
|||
Unit-tests for the dispatch project
|
||||
"""
|
||||
|
||||
from test_saferef import *
|
||||
from test_dispatcher import *
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .test_saferef import *
|
||||
from .test_dispatcher import *
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import gc
|
||||
import sys
|
||||
import time
|
||||
|
||||
from django.dispatch import Signal
|
||||
from django.utils import unittest
|
||||
|
||||
|
||||
if sys.platform.startswith('java'):
|
||||
def garbage_collect():
|
||||
"""Run the garbage collector and wait a bit to let it do his work"""
|
||||
import time
|
||||
gc.collect()
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
|
|
|
@ -3,6 +3,7 @@ Model for testing arithmetic expressions.
|
|||
"""
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Number(models.Model):
|
||||
integer = models.IntegerField(db_column='the_integer')
|
||||
float = models.FloatField(null=True, db_column='the_float')
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
"""
|
||||
Spanning tests for all the operations that F() expressions can perform.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from django.db import connection
|
||||
from django.db.models import F
|
||||
from django.test import TestCase, Approximate, skipUnlessDBFeature
|
||||
|
||||
from regressiontests.expressions_regress.models import Number, Experiment
|
||||
from .models import Number, Experiment
|
||||
|
||||
|
||||
class ExpressionsRegressTests(TestCase):
|
||||
|
@ -240,7 +242,7 @@ class FTimeDeltaTests(TestCase):
|
|||
# e2: started three days after assigned, small duration
|
||||
end = stime+delta2
|
||||
e2 = Experiment.objects.create(name='e2',
|
||||
assigned=sday-datetime.timedelta(3), start=stime, end=end,
|
||||
assigned=sday-datetime.timedelta(3), start=stime, end=end,
|
||||
completed=end.date())
|
||||
self.deltas.append(delta2)
|
||||
self.delays.append(e2.start-
|
||||
|
@ -293,22 +295,22 @@ class FTimeDeltaTests(TestCase):
|
|||
def test_exclude(self):
|
||||
for i in range(len(self.deltas)):
|
||||
delta = self.deltas[i]
|
||||
test_set = [e.name for e in
|
||||
test_set = [e.name for e in
|
||||
Experiment.objects.exclude(end__lt=F('start')+delta)]
|
||||
self.assertEqual(test_set, self.expnames[i:])
|
||||
|
||||
test_set = [e.name for e in
|
||||
test_set = [e.name for e in
|
||||
Experiment.objects.exclude(end__lte=F('start')+delta)]
|
||||
self.assertEqual(test_set, self.expnames[i+1:])
|
||||
|
||||
def test_date_comparison(self):
|
||||
for i in range(len(self.days_long)):
|
||||
days = self.days_long[i]
|
||||
test_set = [e.name for e in
|
||||
test_set = [e.name for e in
|
||||
Experiment.objects.filter(completed__lt=F('assigned')+days)]
|
||||
self.assertEqual(test_set, self.expnames[:i])
|
||||
|
||||
test_set = [e.name for e in
|
||||
test_set = [e.name for e in
|
||||
Experiment.objects.filter(completed__lte=F('assigned')+days)]
|
||||
self.assertEqual(test_set, self.expnames[:i+1])
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import datetime
|
|||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
||||
|
||||
class RevisionableModel(models.Model):
|
||||
base = models.ForeignKey('self', null=True)
|
||||
title = models.CharField(blank=True, max_length=255)
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
from django.test import TestCase
|
||||
|
||||
from django.utils.datastructures import SortedDict
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from regressiontests.extra_regress.models import TestObject, Order, RevisionableModel
|
||||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
from django.utils.datastructures import SortedDict
|
||||
|
||||
from .models import TestObject, Order, RevisionableModel
|
||||
|
||||
|
||||
class ExtraRegressTests(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import errno
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import tempfile
|
||||
import os
|
||||
from django.db import models
|
||||
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.db import models
|
||||
|
||||
|
||||
temp_storage = FileSystemStorage(tempfile.mkdtemp())
|
||||
UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload')
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#! -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import base64
|
||||
import errno
|
||||
import hashlib
|
||||
|
@ -11,11 +13,10 @@ from django.core.files import temp as tempfile
|
|||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.http.multipartparser import MultiPartParser
|
||||
from django.test import TestCase, client
|
||||
from django.utils import simplejson
|
||||
from django.utils import unittest
|
||||
from django.utils import simplejson, unittest
|
||||
|
||||
from models import FileModel, temp_storage, UPLOAD_TO
|
||||
import uploadhandler
|
||||
from . import uploadhandler
|
||||
from .models import FileModel, temp_storage, UPLOAD_TO
|
||||
|
||||
|
||||
UNICODE_FILENAME = u'test-0123456789_中文_Orléans.jpg'
|
||||
|
|
|
@ -4,24 +4,25 @@ Upload handlers to test the upload API.
|
|||
|
||||
from django.core.files.uploadhandler import FileUploadHandler, StopUpload
|
||||
|
||||
|
||||
class QuotaUploadHandler(FileUploadHandler):
|
||||
"""
|
||||
This test upload handler terminates the connection if more than a quota
|
||||
(5MB) is uploaded.
|
||||
"""
|
||||
|
||||
|
||||
QUOTA = 5 * 2**20 # 5 MB
|
||||
|
||||
|
||||
def __init__(self, request=None):
|
||||
super(QuotaUploadHandler, self).__init__(request)
|
||||
self.total_upload = 0
|
||||
|
||||
|
||||
def receive_data_chunk(self, raw_data, start):
|
||||
self.total_upload += len(raw_data)
|
||||
if self.total_upload >= self.QUOTA:
|
||||
raise StopUpload(connection_reset=True)
|
||||
return raw_data
|
||||
|
||||
|
||||
def file_complete(self, file_size):
|
||||
return None
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import patterns
|
||||
import views
|
||||
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^upload/$', views.file_upload_view),
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from django.core.files.uploadedfile import UploadedFile
|
||||
from django.http import HttpResponse, HttpResponseServerError
|
||||
from django.utils import simplejson
|
||||
from models import FileModel, UPLOAD_TO
|
||||
from uploadhandler import QuotaUploadHandler, ErroringUploadHandler
|
||||
from tests import UNICODE_FILENAME
|
||||
|
||||
from .models import FileModel, UPLOAD_TO
|
||||
from .tests import UNICODE_FILENAME
|
||||
from .uploadhandler import QuotaUploadHandler, ErroringUploadHandler
|
||||
|
||||
|
||||
def file_upload_view(request):
|
||||
"""
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.db import models
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Animal(models.Model):
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Unittests for fixtures.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import re
|
||||
try:
|
||||
|
@ -8,21 +10,16 @@ except ImportError:
|
|||
from StringIO import StringIO
|
||||
|
||||
from django.core import management
|
||||
from django.core.management.commands.dumpdata import sort_dependencies
|
||||
from django.core.management.base import CommandError
|
||||
from django.db.models import signals
|
||||
from django.core.management.commands.dumpdata import sort_dependencies
|
||||
from django.db import transaction
|
||||
from django.db.models import signals
|
||||
from django.test import (TestCase, TransactionTestCase, skipIfDBFeature,
|
||||
skipUnlessDBFeature)
|
||||
|
||||
from models import Animal, Stuff
|
||||
from models import Absolute, Parent, Child
|
||||
from models import Article, Widget
|
||||
from models import Store, Person, Book
|
||||
from models import NKChild, RefToNKChild
|
||||
from models import Circle1, Circle2, Circle3
|
||||
from models import ExternalDependency
|
||||
from models import Thingy
|
||||
from .models import (Animal, Stuff, Absolute, Parent, Child, Article, Widget,
|
||||
Store, Person, Book, NKChild, RefToNKChild, Circle1, Circle2, Circle3,
|
||||
ExternalDependency, Thingy)
|
||||
|
||||
|
||||
pre_save_checks = []
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
import datetime
|
||||
import tempfile
|
||||
|
||||
from django.db import models
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.db import models
|
||||
|
||||
|
||||
temp_storage_location = tempfile.mkdtemp()
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
from error_messages import *
|
||||
from extra import *
|
||||
from fields import FieldsTests
|
||||
from forms import *
|
||||
from formsets import *
|
||||
from input_formats import *
|
||||
from media import *
|
||||
from models import *
|
||||
from regressions import *
|
||||
from util import *
|
||||
from validators import TestFieldWithValidators
|
||||
from widgets import *
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .error_messages import *
|
||||
from .extra import *
|
||||
from .fields import FieldsTests
|
||||
from .forms import *
|
||||
from .formsets import *
|
||||
from .input_formats import *
|
||||
from .media import *
|
||||
from .models import *
|
||||
from .regressions import *
|
||||
from .util import *
|
||||
from .validators import TestFieldWithValidators
|
||||
from .widgets import *
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.forms import *
|
||||
from django.test import TestCase
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils import unittest
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from regressiontests.forms.tests.fields import verify_exists_urls
|
||||
from .fields import verify_exists_urls
|
||||
|
||||
|
||||
class AssertFormErrorsMixin(object):
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.forms import *
|
||||
from django.forms.extras import SelectDateWidget
|
||||
from django.forms.util import ErrorList
|
||||
from django.utils import translation
|
||||
from django.utils import unittest
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.encoding import smart_unicode
|
||||
from error_messages import AssertFormErrorsMixin
|
||||
from django.utils import translation, unittest
|
||||
from django.utils.encoding import force_unicode, smart_unicode
|
||||
|
||||
from .error_messages import AssertFormErrorsMixin
|
||||
|
||||
|
||||
class GetDate(Form):
|
||||
mydate = DateField(widget=SelectDateWidget)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue