diff --git a/tests/regressiontests/admin_changelist/admin.py b/tests/regressiontests/admin_changelist/admin.py index 9490cd54e26..19c2b24028e 100644 --- a/tests/regressiontests/admin_changelist/admin.py +++ b/tests/regressiontests/admin_changelist/admin.py @@ -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): diff --git a/tests/regressiontests/admin_changelist/models.py b/tests/regressiontests/admin_changelist/models.py index 509d37cc8c0..363b5dbed53 100644 --- a/tests/regressiontests/admin_changelist/models.py +++ b/tests/regressiontests/admin_changelist/models.py @@ -1,5 +1,6 @@ from django.db import models + class Parent(models.Model): name = models.CharField(max_length=128) diff --git a/tests/regressiontests/admin_changelist/tests.py b/tests/regressiontests/admin_changelist/tests.py index 9347dbf382b..5f2ebff43fe 100644 --- a/tests/regressiontests/admin_changelist/tests.py +++ b/tests/regressiontests/admin_changelist/tests.py @@ -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): diff --git a/tests/regressiontests/admin_changelist/urls.py b/tests/regressiontests/admin_changelist/urls.py index 017a0010ae1..a5d927e20b8 100644 --- a/tests/regressiontests/admin_changelist/urls.py +++ b/tests/regressiontests/admin_changelist/urls.py @@ -1,6 +1,7 @@ from django.conf.urls import patterns, include -import admin +from . import admin + urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), diff --git a/tests/regressiontests/admin_custom_urls/tests.py b/tests/regressiontests/admin_custom_urls/tests.py index cfc6b8583e2..13d065a9103 100644 --- a/tests/regressiontests/admin_custom_urls/tests.py +++ b/tests/regressiontests/admin_custom_urls/tests.py @@ -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): diff --git a/tests/regressiontests/admin_filters/models.py b/tests/regressiontests/admin_filters/models.py index fbf14e87c3a..ac43263d2e1 100644 --- a/tests/regressiontests/admin_filters/models.py +++ b/tests/regressiontests/admin_filters/models.py @@ -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) diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py index 7f52f9c20db..fdbd4375c18 100644 --- a/tests/regressiontests/admin_filters/tests.py +++ b/tests/regressiontests/admin_filters/tests.py @@ -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): diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py index 619c2bf3b4f..c2f10c0678e 100644 --- a/tests/regressiontests/admin_inlines/tests.py +++ b/tests/regressiontests/admin_inlines/tests.py @@ -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): diff --git a/tests/regressiontests/admin_inlines/urls.py b/tests/regressiontests/admin_inlines/urls.py index 017a0010ae1..cf18ef97cf1 100644 --- a/tests/regressiontests/admin_inlines/urls.py +++ b/tests/regressiontests/admin_inlines/urls.py @@ -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)), diff --git a/tests/regressiontests/admin_ordering/models.py b/tests/regressiontests/admin_ordering/models.py index 7c92b42010d..195b3c36946 100644 --- a/tests/regressiontests/admin_ordering/models.py +++ b/tests/regressiontests/admin_ordering/models.py @@ -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) diff --git a/tests/regressiontests/admin_ordering/tests.py b/tests/regressiontests/admin_ordering/tests.py index 9c14706aa5d..b82f150f408 100644 --- a/tests/regressiontests/admin_ordering/tests.py +++ b/tests/regressiontests/admin_ordering/tests.py @@ -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): diff --git a/tests/regressiontests/admin_registration/models.py b/tests/regressiontests/admin_registration/models.py index 61689f31b72..c6f42fd1f4a 100644 --- a/tests/regressiontests/admin_registration/models.py +++ b/tests/regressiontests/admin_registration/models.py @@ -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) diff --git a/tests/regressiontests/admin_registration/tests.py b/tests/regressiontests/admin_registration/tests.py index 92e9d8a21e5..1ba8bb1f763 100644 --- a/tests/regressiontests/admin_registration/tests.py +++ b/tests/regressiontests/admin_registration/tests.py @@ -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'] diff --git a/tests/regressiontests/admin_scripts/app_with_import/models.py b/tests/regressiontests/admin_scripts/app_with_import/models.py index 06ca0e8a343..17a892bd172 100644 --- a/tests/regressiontests/admin_scripts/app_with_import/models.py +++ b/tests/regressiontests/admin_scripts/app_with_import/models.py @@ -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. diff --git a/tests/regressiontests/admin_scripts/complex_app/admin/foo.py b/tests/regressiontests/admin_scripts/complex_app/admin/foo.py index 1b933d028d5..1ed704a66bc 100644 --- a/tests/regressiontests/admin_scripts/complex_app/admin/foo.py +++ b/tests/regressiontests/admin_scripts/complex_app/admin/foo.py @@ -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) diff --git a/tests/regressiontests/admin_scripts/complex_app/models/__init__.py b/tests/regressiontests/admin_scripts/complex_app/models/__init__.py index a4d6d9539a9..7b647e74b16 100644 --- a/tests/regressiontests/admin_scripts/complex_app/models/__init__.py +++ b/tests/regressiontests/admin_scripts/complex_app/models/__init__.py @@ -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'] diff --git a/tests/regressiontests/admin_scripts/complex_app/models/bar.py b/tests/regressiontests/admin_scripts/complex_app/models/bar.py index a5d8853fe45..15956f7a50f 100644 --- a/tests/regressiontests/admin_scripts/complex_app/models/bar.py +++ b/tests/regressiontests/admin_scripts/complex_app/models/bar.py @@ -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: diff --git a/tests/regressiontests/admin_scripts/complex_app/models/foo.py b/tests/regressiontests/admin_scripts/complex_app/models/foo.py index 70c285e392b..914cf3b8b53 100644 --- a/tests/regressiontests/admin_scripts/complex_app/models/foo.py +++ b/tests/regressiontests/admin_scripts/complex_app/models/foo.py @@ -1,5 +1,6 @@ from django.db import models + class Foo(models.Model): name = models.CharField(max_length=5) class Meta: diff --git a/tests/regressiontests/admin_scripts/management/commands/app_command.py b/tests/regressiontests/admin_scripts/management/commands/app_command.py index f72e912ac0d..6adab6eafd7 100644 --- a/tests/regressiontests/admin_scripts/management/commands/app_command.py +++ b/tests/regressiontests/admin_scripts/management/commands/app_command.py @@ -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())) - + diff --git a/tests/regressiontests/admin_scripts/management/commands/base_command.py b/tests/regressiontests/admin_scripts/management/commands/base_command.py index 438f7038ca5..05fbcbc9c38 100644 --- a/tests/regressiontests/admin_scripts/management/commands/base_command.py +++ b/tests/regressiontests/admin_scripts/management/commands/base_command.py @@ -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'), diff --git a/tests/regressiontests/admin_scripts/management/commands/label_command.py b/tests/regressiontests/admin_scripts/management/commands/label_command.py index 2b735c8e60b..74cbd6991d5 100644 --- a/tests/regressiontests/admin_scripts/management/commands/label_command.py +++ b/tests/regressiontests/admin_scripts/management/commands/label_command.py @@ -1,5 +1,6 @@ from django.core.management.base import LabelCommand + class Command(LabelCommand): help = "Test Label-based commands" requires_model_validation = False diff --git a/tests/regressiontests/admin_scripts/management/commands/noargs_command.py b/tests/regressiontests/admin_scripts/management/commands/noargs_command.py index 683eb7a62ce..0c272963b19 100644 --- a/tests/regressiontests/admin_scripts/management/commands/noargs_command.py +++ b/tests/regressiontests/admin_scripts/management/commands/noargs_command.py @@ -1,5 +1,6 @@ from django.core.management.base import NoArgsCommand + class Command(NoArgsCommand): help = "Test No-args commands" requires_model_validation = False diff --git a/tests/regressiontests/admin_scripts/models.py b/tests/regressiontests/admin_scripts/models.py index 96a40d22b7a..da803d01746 100644 --- a/tests/regressiontests/admin_scripts/models.py +++ b/tests/regressiontests/admin_scripts/models.py @@ -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') - \ No newline at end of file diff --git a/tests/regressiontests/admin_scripts/simple_app/models.py b/tests/regressiontests/admin_scripts/simple_app/models.py index 65b30ed38a0..b89f4b898be 100644 --- a/tests/regressiontests/admin_scripts/simple_app/models.py +++ b/tests/regressiontests/admin_scripts/simple_app/models.py @@ -1 +1,3 @@ -from admin_scripts.complex_app.models.bar import Bar +from __future__ import absolute_import + +from ..complex_app.models.bar import Bar diff --git a/tests/regressiontests/admin_util/models.py b/tests/regressiontests/admin_util/models.py index d5e29e9aee9..0e81df38174 100644 --- a/tests/regressiontests/admin_util/models.py +++ b/tests/regressiontests/admin_util/models.py @@ -1,5 +1,6 @@ from django.db import models + class Article(models.Model): """ A simple Article model for testing diff --git a/tests/regressiontests/admin_util/tests.py b/tests/regressiontests/admin_util/tests.py index 683a2d4e9c9..eb110159c4e 100644 --- a/tests/regressiontests/admin_util/tests.py +++ b/tests/regressiontests/admin_util/tests.py @@ -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): diff --git a/tests/regressiontests/admin_validation/tests.py b/tests/regressiontests/admin_validation/tests.py index b956121ad60..be2500a803e 100644 --- a/tests/regressiontests/admin_validation/tests.py +++ b/tests/regressiontests/admin_validation/tests.py @@ -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 diff --git a/tests/regressiontests/admin_views/admin.py b/tests/regressiontests/admin_views/admin.py index e4aae4fed9d..f506fb20785 100644 --- a/tests/regressiontests/admin_views/admin.py +++ b/tests/regressiontests/admin_views/admin.py @@ -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): diff --git a/tests/regressiontests/admin_views/customadmin.py b/tests/regressiontests/admin_views/customadmin.py index a696e9f565c..38ed38a8a4d 100644 --- a/tests/regressiontests/admin_views/customadmin.py +++ b/tests/regressiontests/admin_views/customadmin.py @@ -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 diff --git a/tests/regressiontests/admin_views/forms.py b/tests/regressiontests/admin_views/forms.py index a030c2a8d09..e8493df95b6 100644 --- a/tests/regressiontests/admin_views/forms.py +++ b/tests/regressiontests/admin_views/forms.py @@ -1,6 +1,7 @@ from django import forms from django.contrib.admin.forms import AdminAuthenticationForm + class CustomAdminAuthenticationForm(AdminAuthenticationForm): def clean_username(self): diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py index bb8d026e261..8224383209d 100644 --- a/tests/regressiontests/admin_views/models.py +++ b/tests/regressiontests/admin_views/models.py @@ -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): diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index b15e97af1f3..52664a0207a 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -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): diff --git a/tests/regressiontests/admin_views/urls.py b/tests/regressiontests/admin_views/urls.py index e436665d6d7..03bfbf08129 100644 --- a/tests/regressiontests/admin_views/urls.py +++ b/tests/regressiontests/admin_views/urls.py @@ -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')), diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py index a7bfe55b2aa..08a1a597667 100644 --- a/tests/regressiontests/admin_widgets/tests.py +++ b/tests/regressiontests/admin_widgets/tests.py @@ -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, diff --git a/tests/regressiontests/admin_widgets/urls.py b/tests/regressiontests/admin_widgets/urls.py index 9e6bc1290f7..aecee90b7f0 100644 --- a/tests/regressiontests/admin_widgets/urls.py +++ b/tests/regressiontests/admin_widgets/urls.py @@ -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)), diff --git a/tests/regressiontests/admin_widgets/widgetadmin.py b/tests/regressiontests/admin_widgets/widgetadmin.py index ea738125fef..5b8cec6e2db 100644 --- a/tests/regressiontests/admin_widgets/widgetadmin.py +++ b/tests/regressiontests/admin_widgets/widgetadmin.py @@ -1,9 +1,12 @@ """ """ +from __future__ import absolute_import + from django.contrib import admin -import models +from . import models + class WidgetAdmin(admin.AdminSite): pass diff --git a/tests/regressiontests/aggregation_regress/tests.py b/tests/regressiontests/aggregation_regress/tests.py index acdc59ae973..1498f193129 100644 --- a/tests/regressiontests/aggregation_regress/tests.py +++ b/tests/regressiontests/aggregation_regress/tests.py @@ -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): diff --git a/tests/regressiontests/app_loading/tests.py b/tests/regressiontests/app_loading/tests.py index 749f24aeb1d..cec565ab08a 100644 --- a/tests/regressiontests/app_loading/tests.py +++ b/tests/regressiontests/app_loading/tests.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import copy import os import sys diff --git a/tests/regressiontests/backends/models.py b/tests/regressiontests/backends/models.py index 89e3fd27ffb..1a78a87ecab 100644 --- a/tests/regressiontests/backends/models.py +++ b/tests/regressiontests/backends/models.py @@ -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): diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py index 27d3dfdddcd..f2bd71df3a6 100644 --- a/tests/regressiontests/backends/tests.py +++ b/tests/regressiontests/backends/tests.py @@ -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): diff --git a/tests/regressiontests/bash_completion/tests.py b/tests/regressiontests/bash_completion/tests.py index f9670346a1f..0206c37482a 100644 --- a/tests/regressiontests/bash_completion/tests.py +++ b/tests/regressiontests/bash_completion/tests.py @@ -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. diff --git a/tests/regressiontests/bug639/models.py b/tests/regressiontests/bug639/models.py index b7e38809d98..e641555c878 100644 --- a/tests/regressiontests/bug639/models.py +++ b/tests/regressiontests/bug639/models.py @@ -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) diff --git a/tests/regressiontests/bug639/tests.py b/tests/regressiontests/bug639/tests.py index 345ce456ea7..9d305175206 100644 --- a/tests/regressiontests/bug639/tests.py +++ b/tests/regressiontests/bug639/tests.py @@ -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): diff --git a/tests/regressiontests/bug8245/admin.py b/tests/regressiontests/bug8245/admin.py index 18122696b68..d8211907638 100644 --- a/tests/regressiontests/bug8245/admin.py +++ b/tests/regressiontests/bug8245/admin.py @@ -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) diff --git a/tests/regressiontests/bug8245/models.py b/tests/regressiontests/bug8245/models.py index 5643955df34..a093db4bd6f 100644 --- a/tests/regressiontests/bug8245/models.py +++ b/tests/regressiontests/bug8245/models.py @@ -1,4 +1,5 @@ from django.db import models + class Story(models.Model): title = models.CharField(max_length=10) diff --git a/tests/regressiontests/bug8245/tests.py b/tests/regressiontests/bug8245/tests.py index df35b8c7741..b756b841449 100644 --- a/tests/regressiontests/bug8245/tests.py +++ b/tests/regressiontests/bug8245/tests.py @@ -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") \ No newline at end of file diff --git a/tests/regressiontests/bulk_create/tests.py b/tests/regressiontests/bulk_create/tests.py index 18383b52ed6..0fa142b7959 100644 --- a/tests/regressiontests/bulk_create/tests.py +++ b/tests/regressiontests/bulk_create/tests.py @@ -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): diff --git a/tests/regressiontests/cache/liberal_backend.py b/tests/regressiontests/cache/liberal_backend.py index cc15b664659..b72013c6a84 100644 --- a/tests/regressiontests/cache/liberal_backend.py +++ b/tests/regressiontests/cache/liberal_backend.py @@ -1,5 +1,6 @@ from django.core.cache.backends.locmem import LocMemCache + class LiberalKeyValidationMixin(object): def validate_key(self, key): pass diff --git a/tests/regressiontests/cache/models.py b/tests/regressiontests/cache/models.py index 643fd22629e..31b988a86d4 100644 --- a/tests/regressiontests/cache/models.py +++ b/tests/regressiontests/cache/models.py @@ -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() diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py index 07bcab7fbc5..33ed4d7c7e7 100644 --- a/tests/regressiontests/cache/tests.py +++ b/tests/regressiontests/cache/tests.py @@ -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(): diff --git a/tests/regressiontests/comment_tests/custom_comments/forms.py b/tests/regressiontests/comment_tests/custom_comments/forms.py index b788cdcf298..07918ddb8ce 100644 --- a/tests/regressiontests/comment_tests/custom_comments/forms.py +++ b/tests/regressiontests/comment_tests/custom_comments/forms.py @@ -1,4 +1,5 @@ from django import forms + class CustomCommentForm(forms.Form): pass diff --git a/tests/regressiontests/comment_tests/custom_comments/models.py b/tests/regressiontests/comment_tests/custom_comments/models.py index 592ad795864..646f6255f23 100644 --- a/tests/regressiontests/comment_tests/custom_comments/models.py +++ b/tests/regressiontests/comment_tests/custom_comments/models.py @@ -1,4 +1,5 @@ from django.db import models + class CustomComment(models.Model): pass diff --git a/tests/regressiontests/comment_tests/custom_comments/views.py b/tests/regressiontests/comment_tests/custom_comments/views.py index 93cea9d5919..1c3a974367c 100644 --- a/tests/regressiontests/comment_tests/custom_comments/views.py +++ b/tests/regressiontests/comment_tests/custom_comments/views.py @@ -1,5 +1,6 @@ from django.http import HttpResponse + def custom_submit_comment(request): return HttpResponse("Hello from the custom submit comment view.") diff --git a/tests/regressiontests/comment_tests/models.py b/tests/regressiontests/comment_tests/models.py index dc6c842ab69..4093af14b5c 100644 --- a/tests/regressiontests/comment_tests/models.py +++ b/tests/regressiontests/comment_tests/models.py @@ -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) - \ No newline at end of file diff --git a/tests/regressiontests/comment_tests/tests/__init__.py b/tests/regressiontests/comment_tests/tests/__init__.py index 88c6f33203d..f5f4dac77bc 100644 --- a/tests/regressiontests/comment_tests/tests/__init__.py +++ b/tests/regressiontests/comment_tests/tests/__init__.py @@ -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 diff --git a/tests/regressiontests/comment_tests/tests/app_api_tests.py b/tests/regressiontests/comment_tests/tests/app_api_tests.py index 4015487e3b7..8a63e8c188e 100644 --- a/tests/regressiontests/comment_tests/tests/app_api_tests.py +++ b/tests/regressiontests/comment_tests/tests/app_api_tests.py @@ -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""" diff --git a/tests/regressiontests/comment_tests/tests/comment_form_tests.py b/tests/regressiontests/comment_tests/tests/comment_form_tests.py index 2c5e1fe5511..39ba57928d2 100644 --- a/tests/regressiontests/comment_tests/tests/comment_form_tests.py +++ b/tests/regressiontests/comment_tests/tests/comment_form_tests.py @@ -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): diff --git a/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py b/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py index ac9bde6fedb..eab87ef53b8 100644 --- a/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py +++ b/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py @@ -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 diff --git a/tests/regressiontests/comment_tests/tests/comment_view_tests.py b/tests/regressiontests/comment_tests/tests/comment_view_tests.py index e3f3bbeff74..5edc58fe2d6 100644 --- a/tests/regressiontests/comment_tests/tests/comment_view_tests.py +++ b/tests/regressiontests/comment_tests/tests/comment_view_tests.py @@ -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\d+$)') diff --git a/tests/regressiontests/comment_tests/tests/feed_tests.py b/tests/regressiontests/comment_tests/tests/feed_tests.py index 4497f95c6ec..6fe747c22d8 100644 --- a/tests/regressiontests/comment_tests/tests/feed_tests.py +++ b/tests/regressiontests/comment_tests/tests/feed_tests.py @@ -1,4 +1,6 @@ -from regressiontests.comment_tests.tests import CommentTestCase +from __future__ import absolute_import + +from . import CommentTestCase class CommentFeedTests(CommentTestCase): diff --git a/tests/regressiontests/comment_tests/tests/model_tests.py b/tests/regressiontests/comment_tests/tests/model_tests.py index 2cbf66f07ed..c7eaa4cef33 100644 --- a/tests/regressiontests/comment_tests/tests/model_tests.py +++ b/tests/regressiontests/comment_tests/tests/model_tests.py @@ -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): diff --git a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py index c9be06a3403..e9d2fb15785 100644 --- a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py +++ b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py @@ -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): diff --git a/tests/regressiontests/comment_tests/tests/templatetag_tests.py b/tests/regressiontests/comment_tests/tests/templatetag_tests.py index 99c3ca37fa3..930f09d339a 100644 --- a/tests/regressiontests/comment_tests/tests/templatetag_tests.py +++ b/tests/regressiontests/comment_tests/tests/templatetag_tests.py @@ -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): diff --git a/tests/regressiontests/comment_tests/urls.py b/tests/regressiontests/comment_tests/urls.py index d1a4ec01c22..b2f676786fe 100644 --- a/tests/regressiontests/comment_tests/urls.py +++ b/tests/regressiontests/comment_tests/urls.py @@ -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('', diff --git a/tests/regressiontests/conditional_processing/models.py b/tests/regressiontests/conditional_processing/models.py index 0f9bb52b523..f7f48bc9c8f 100644 --- a/tests/regressiontests/conditional_processing/models.py +++ b/tests/regressiontests/conditional_processing/models.py @@ -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' diff --git a/tests/regressiontests/conditional_processing/urls.py b/tests/regressiontests/conditional_processing/urls.py index d84030e393b..1ed7b1264a1 100644 --- a/tests/regressiontests/conditional_processing/urls.py +++ b/tests/regressiontests/conditional_processing/urls.py @@ -1,5 +1,7 @@ from django.conf.urls import patterns -import views + +from . import views + urlpatterns = patterns('', ('^condition/$', views.index), diff --git a/tests/regressiontests/conditional_processing/views.py b/tests/regressiontests/conditional_processing/views.py index df4928133d0..2188c9b462d 100644 --- a/tests/regressiontests/conditional_processing/views.py +++ b/tests/regressiontests/conditional_processing/views.py @@ -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) diff --git a/tests/regressiontests/context_processors/urls.py b/tests/regressiontests/context_processors/urls.py index 29153fadf23..757017c9ca9 100644 --- a/tests/regressiontests/context_processors/urls.py +++ b/tests/regressiontests/context_processors/urls.py @@ -1,6 +1,8 @@ +from __future__ import absolute_import + from django.conf.urls import patterns, url -import views +from . import views urlpatterns = patterns('', diff --git a/tests/regressiontests/csrf_tests/tests.py b/tests/regressiontests/csrf_tests/tests.py index c5f9f3632d1..f2fb4090762 100644 --- a/tests/regressiontests/csrf_tests/tests.py +++ b/tests/regressiontests/csrf_tests/tests.py @@ -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(): diff --git a/tests/regressiontests/custom_columns_regress/models.py b/tests/regressiontests/custom_columns_regress/models.py index 93de2370aff..fcb5a4be44c 100644 --- a/tests/regressiontests/custom_columns_regress/models.py +++ b/tests/regressiontests/custom_columns_regress/models.py @@ -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) diff --git a/tests/regressiontests/custom_columns_regress/tests.py b/tests/regressiontests/custom_columns_regress/tests.py index a5c4d12e907..7cc66ca2a68 100644 --- a/tests/regressiontests/custom_columns_regress/tests.py +++ b/tests/regressiontests/custom_columns_regress/tests.py @@ -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""" diff --git a/tests/regressiontests/custom_managers_regress/models.py b/tests/regressiontests/custom_managers_regress/models.py index 747972b4413..3c4e621769d 100644 --- a/tests/regressiontests/custom_managers_regress/models.py +++ b/tests/regressiontests/custom_managers_regress/models.py @@ -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. diff --git a/tests/regressiontests/custom_managers_regress/tests.py b/tests/regressiontests/custom_managers_regress/tests.py index 6dd668a13d5..5a9cd91d596 100644 --- a/tests/regressiontests/custom_managers_regress/tests.py +++ b/tests/regressiontests/custom_managers_regress/tests.py @@ -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): diff --git a/tests/regressiontests/datatypes/models.py b/tests/regressiontests/datatypes/models.py index f6fb72dbea6..332ce843075 100644 --- a/tests/regressiontests/datatypes/models.py +++ b/tests/regressiontests/datatypes/models.py @@ -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) diff --git a/tests/regressiontests/datatypes/tests.py b/tests/regressiontests/datatypes/tests.py index 2d40fecfd1e..3cf11024fdb 100644 --- a/tests/regressiontests/datatypes/tests.py +++ b/tests/regressiontests/datatypes/tests.py @@ -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): diff --git a/tests/regressiontests/dates/tests.py b/tests/regressiontests/dates/tests.py index 769d0742152..de28cac4366 100644 --- a/tests/regressiontests/dates/tests.py +++ b/tests/regressiontests/dates/tests.py @@ -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): diff --git a/tests/regressiontests/decorators/tests.py b/tests/regressiontests/decorators/tests.py index f1d1c109758..51f75d7b563 100644 --- a/tests/regressiontests/decorators/tests.py +++ b/tests/regressiontests/decorators/tests.py @@ -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): diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py index cbd4776a500..94068994689 100644 --- a/tests/regressiontests/defaultfilters/tests.py +++ b/tests/regressiontests/defaultfilters/tests.py @@ -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): diff --git a/tests/regressiontests/defer_regress/models.py b/tests/regressiontests/defer_regress/models.py index 73cefb130d3..812d2da2063 100644 --- a/tests/regressiontests/defer_regress/models.py +++ b/tests/regressiontests/defer_regress/models.py @@ -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") diff --git a/tests/regressiontests/defer_regress/tests.py b/tests/regressiontests/defer_regress/tests.py index 14fa13395d3..98058ef454b 100644 --- a/tests/regressiontests/defer_regress/tests.py +++ b/tests/regressiontests/defer_regress/tests.py @@ -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): diff --git a/tests/regressiontests/delete_regress/models.py b/tests/regressiontests/delete_regress/models.py index 8e3d0d55b15..622fbc8104f 100644 --- a/tests/regressiontests/delete_regress/models.py +++ b/tests/regressiontests/delete_regress/models.py @@ -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) diff --git a/tests/regressiontests/delete_regress/tests.py b/tests/regressiontests/delete_regress/tests.py index 22b4833a8f1..c2a2171d897 100644 --- a/tests/regressiontests/delete_regress/tests.py +++ b/tests/regressiontests/delete_regress/tests.py @@ -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 diff --git a/tests/regressiontests/dispatch/tests/__init__.py b/tests/regressiontests/dispatch/tests/__init__.py index 150bb01dc0a..4e317108148 100644 --- a/tests/regressiontests/dispatch/tests/__init__.py +++ b/tests/regressiontests/dispatch/tests/__init__.py @@ -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 * diff --git a/tests/regressiontests/dispatch/tests/test_dispatcher.py b/tests/regressiontests/dispatch/tests/test_dispatcher.py index a16d8e24f5a..ee63e22b996 100644 --- a/tests/regressiontests/dispatch/tests/test_dispatcher.py +++ b/tests/regressiontests/dispatch/tests/test_dispatcher.py @@ -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: diff --git a/tests/regressiontests/expressions_regress/models.py b/tests/regressiontests/expressions_regress/models.py index 56c3746b91b..0ebccb50846 100644 --- a/tests/regressiontests/expressions_regress/models.py +++ b/tests/regressiontests/expressions_regress/models.py @@ -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') diff --git a/tests/regressiontests/expressions_regress/tests.py b/tests/regressiontests/expressions_regress/tests.py index 497a8439b59..80ddfadbe7f 100644 --- a/tests/regressiontests/expressions_regress/tests.py +++ b/tests/regressiontests/expressions_regress/tests.py @@ -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]) diff --git a/tests/regressiontests/extra_regress/models.py b/tests/regressiontests/extra_regress/models.py index 11218202f03..868331e5087 100644 --- a/tests/regressiontests/extra_regress/models.py +++ b/tests/regressiontests/extra_regress/models.py @@ -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) diff --git a/tests/regressiontests/extra_regress/tests.py b/tests/regressiontests/extra_regress/tests.py index 5f779be7519..67efb428dde 100644 --- a/tests/regressiontests/extra_regress/tests.py +++ b/tests/regressiontests/extra_regress/tests.py @@ -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): diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py index 6a7a46af21b..d4530bb0b1f 100644 --- a/tests/regressiontests/file_storage/tests.py +++ b/tests/regressiontests/file_storage/tests.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -import os import errno +import os import shutil import sys import tempfile diff --git a/tests/regressiontests/file_uploads/models.py b/tests/regressiontests/file_uploads/models.py index 9d020509afd..28e71c44bc8 100644 --- a/tests/regressiontests/file_uploads/models.py +++ b/tests/regressiontests/file_uploads/models.py @@ -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') diff --git a/tests/regressiontests/file_uploads/tests.py b/tests/regressiontests/file_uploads/tests.py index 2be423e028b..ffa2017a5e9 100644 --- a/tests/regressiontests/file_uploads/tests.py +++ b/tests/regressiontests/file_uploads/tests.py @@ -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' diff --git a/tests/regressiontests/file_uploads/uploadhandler.py b/tests/regressiontests/file_uploads/uploadhandler.py index 9f3960a8d87..b30ef136e9d 100644 --- a/tests/regressiontests/file_uploads/uploadhandler.py +++ b/tests/regressiontests/file_uploads/uploadhandler.py @@ -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 diff --git a/tests/regressiontests/file_uploads/urls.py b/tests/regressiontests/file_uploads/urls.py index 904f28bad9e..fc5576828f6 100644 --- a/tests/regressiontests/file_uploads/urls.py +++ b/tests/regressiontests/file_uploads/urls.py @@ -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), diff --git a/tests/regressiontests/file_uploads/views.py b/tests/regressiontests/file_uploads/views.py index c88c77548a9..9fd1a8d5449 100644 --- a/tests/regressiontests/file_uploads/views.py +++ b/tests/regressiontests/file_uploads/views.py @@ -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): """ diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py index b353f809409..b9567429692 100644 --- a/tests/regressiontests/fixtures_regress/models.py +++ b/tests/regressiontests/fixtures_regress/models.py @@ -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): diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py index b8e691490a2..5c448e67b1c 100644 --- a/tests/regressiontests/fixtures_regress/tests.py +++ b/tests/regressiontests/fixtures_regress/tests.py @@ -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 = [] diff --git a/tests/regressiontests/forms/models.py b/tests/regressiontests/forms/models.py index 203980c11c8..d4e693436b7 100644 --- a/tests/regressiontests/forms/models.py +++ b/tests/regressiontests/forms/models.py @@ -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() diff --git a/tests/regressiontests/forms/tests/__init__.py b/tests/regressiontests/forms/tests/__init__.py index 1b615c4583f..721926ec200 100644 --- a/tests/regressiontests/forms/tests/__init__.py +++ b/tests/regressiontests/forms/tests/__init__.py @@ -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 * diff --git a/tests/regressiontests/forms/tests/error_messages.py b/tests/regressiontests/forms/tests/error_messages.py index c54a46331b2..1c262d683da 100644 --- a/tests/regressiontests/forms/tests/error_messages.py +++ b/tests/regressiontests/forms/tests/error_messages.py @@ -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): diff --git a/tests/regressiontests/forms/tests/extra.py b/tests/regressiontests/forms/tests/extra.py index 67a5ffc7b1a..dec97240e07 100644 --- a/tests/regressiontests/forms/tests/extra.py +++ b/tests/regressiontests/forms/tests/extra.py @@ -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) diff --git a/tests/regressiontests/forms/tests/forms.py b/tests/regressiontests/forms/tests/forms.py index ed783af819e..91db44949cc 100644 --- a/tests/regressiontests/forms/tests/forms.py +++ b/tests/regressiontests/forms/tests/forms.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import datetime + from django.core.files.uploadedfile import SimpleUploadedFile from django.forms import * from django.http import QueryDict diff --git a/tests/regressiontests/forms/tests/media.py b/tests/regressiontests/forms/tests/media.py index 71dc0a7b039..69c0af920c9 100644 --- a/tests/regressiontests/forms/tests/media.py +++ b/tests/regressiontests/forms/tests/media.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from django.forms import TextInput, Media, TextInput, CharField, Form, MultiWidget +from django.template import Template, Context from django.test import TestCase from django.test.utils import override_settings -from django.template import Template, Context class FormsMediaTestCase(TestCase): diff --git a/tests/regressiontests/forms/tests/models.py b/tests/regressiontests/forms/tests/models.py index 60fc4e83ba1..89b33097ea7 100644 --- a/tests/regressiontests/forms/tests/models.py +++ b/tests/regressiontests/forms/tests/models.py @@ -1,12 +1,16 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import + import datetime + from django.core.files.uploadedfile import SimpleUploadedFile from django.db import models from django.forms import Form, ModelForm, FileField, ModelChoiceField from django.forms.models import ModelFormMetaclass from django.test import TestCase -from regressiontests.forms.models import (ChoiceOptionModel, ChoiceFieldModel, - FileModel, Group, BoundaryModel, Defaults) + +from ..models import (ChoiceOptionModel, ChoiceFieldModel, FileModel, Group, + BoundaryModel, Defaults) class ChoiceFieldForm(ModelForm): diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py index e6667f7629b..2424bea9035 100644 --- a/tests/regressiontests/forms/tests/widgets.py +++ b/tests/regressiontests/forms/tests/widgets.py @@ -2,6 +2,7 @@ import copy import datetime + from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.forms import *