diff --git a/tests/regressiontests/generic_inline_admin/admin.py b/tests/regressiontests/generic_inline_admin/admin.py
index 87224edab7..73cac7f7c5 100644
--- a/tests/regressiontests/generic_inline_admin/admin.py
+++ b/tests/regressiontests/generic_inline_admin/admin.py
@@ -1,9 +1,12 @@
+from __future__ import absolute_import
+
from django.contrib import admin
from django.contrib.contenttypes import generic
-from models import (Media, PhoneNumber, Episode, EpisodeExtra, Contact,
+from .models import (Media, PhoneNumber, Episode, EpisodeExtra, Contact,
Category, EpisodePermanent, EpisodeMaxNum)
+
site = admin.AdminSite(name="admin")
class MediaInline(generic.GenericTabularInline):
diff --git a/tests/regressiontests/generic_inline_admin/models.py b/tests/regressiontests/generic_inline_admin/models.py
index e78f110416..b9426b4f2a 100644
--- a/tests/regressiontests/generic_inline_admin/models.py
+++ b/tests/regressiontests/generic_inline_admin/models.py
@@ -1,6 +1,6 @@
-from django.db import models
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
+from django.db import models
class Episode(models.Model):
diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
index baea85717b..2c82acfd01 100644
--- a/tests/regressiontests/generic_inline_admin/tests.py
+++ b/tests/regressiontests/generic_inline_admin/tests.py
@@ -1,5 +1,7 @@
# coding: utf-8
+from __future__ import absolute_import
+
from django.conf import settings
from django.contrib import admin
from django.contrib.admin.sites import AdminSite
@@ -9,9 +11,9 @@ from django.forms.models import ModelForm
from django.test import TestCase
# local test models
-from models import (Episode, EpisodeExtra, EpisodeMaxNum, Media,
+from .admin import MediaInline, MediaPermanentInline
+from .models import (Episode, EpisodeExtra, EpisodeMaxNum, Media,
EpisodePermanent, Category)
-from admin import MediaInline, MediaPermanentInline
class GenericAdminViewTest(TestCase):
diff --git a/tests/regressiontests/generic_inline_admin/urls.py b/tests/regressiontests/generic_inline_admin/urls.py
index 03431d3226..88d7b574d4 100644
--- a/tests/regressiontests/generic_inline_admin/urls.py
+++ b/tests/regressiontests/generic_inline_admin/urls.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
from django.conf.urls import patterns, include
-import admin
+from . import admin
urlpatterns = patterns('',
(r'^generic_inline_admin/admin/', include(admin.site.urls)),
diff --git a/tests/regressiontests/generic_relations_regress/models.py b/tests/regressiontests/generic_relations_regress/models.py
index d28385d398..7ec752b02b 100644
--- a/tests/regressiontests/generic_relations_regress/models.py
+++ b/tests/regressiontests/generic_relations_regress/models.py
@@ -1,9 +1,10 @@
-from django.db import models
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
+from django.db import models
-__all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address',
- 'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2',
+
+__all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address',
+ 'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2',
'Contact', 'Organization', 'Note')
class Link(models.Model):
diff --git a/tests/regressiontests/generic_relations_regress/tests.py b/tests/regressiontests/generic_relations_regress/tests.py
index 52731a9a43..4c0f024433 100644
--- a/tests/regressiontests/generic_relations_regress/tests.py
+++ b/tests/regressiontests/generic_relations_regress/tests.py
@@ -1,6 +1,9 @@
-from django.test import TestCase
from django.db.models import Q
-from models import *
+from django.test import TestCase
+
+from .models import (Address, Place, Restaurant, Link, CharLink, TextLink,
+ Person, Contact, Note, Organization, OddRelation1, OddRelation2)
+
class GenericRelationTests(TestCase):
diff --git a/tests/regressiontests/generic_views/base.py b/tests/regressiontests/generic_views/base.py
index 00fa0d9b79..d9debb6627 100644
--- a/tests/regressiontests/generic_views/base.py
+++ b/tests/regressiontests/generic_views/base.py
@@ -1,9 +1,9 @@
import time
-import unittest
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse
from django.test import TestCase, RequestFactory
+from django.utils import unittest
from django.views.generic import View, TemplateView, RedirectView
diff --git a/tests/regressiontests/generic_views/dates.py b/tests/regressiontests/generic_views/dates.py
index a0dd867e71..5e03dbe806 100644
--- a/tests/regressiontests/generic_views/dates.py
+++ b/tests/regressiontests/generic_views/dates.py
@@ -1,9 +1,12 @@
+from __future__ import absolute_import
+
import datetime
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
-from regressiontests.generic_views.models import Book
+from .models import Book
+
class ArchiveIndexViewTests(TestCase):
fixtures = ['generic-views-test-data.json']
diff --git a/tests/regressiontests/generic_views/detail.py b/tests/regressiontests/generic_views/detail.py
index c1cc2fbddb..0b5d8737dd 100644
--- a/tests/regressiontests/generic_views/detail.py
+++ b/tests/regressiontests/generic_views/detail.py
@@ -1,7 +1,9 @@
+from __future__ import absolute_import
+
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
-from regressiontests.generic_views.models import Artist, Author, Page
+from .models import Artist, Author, Page
class DetailViewTest(TestCase):
diff --git a/tests/regressiontests/generic_views/edit.py b/tests/regressiontests/generic_views/edit.py
index 0adcb15afa..182615a86b 100644
--- a/tests/regressiontests/generic_views/edit.py
+++ b/tests/regressiontests/generic_views/edit.py
@@ -1,11 +1,14 @@
+from __future__ import absolute_import
+
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django import forms
from django.test import TestCase
from django.utils.unittest import expectedFailure
-from regressiontests.generic_views.models import Artist, Author
-from regressiontests.generic_views import views
+from . import views
+from .models import Artist, Author
+
class ModelFormMixinTests(TestCase):
def test_get_form(self):
diff --git a/tests/regressiontests/generic_views/forms.py b/tests/regressiontests/generic_views/forms.py
index 7200947781..a78242f555 100644
--- a/tests/regressiontests/generic_views/forms.py
+++ b/tests/regressiontests/generic_views/forms.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
from django import forms
-from regressiontests.generic_views.models import Author
+from .models import Author
class AuthorForm(forms.ModelForm):
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py
index f5bf910894..9ad00edc3b 100644
--- a/tests/regressiontests/generic_views/list.py
+++ b/tests/regressiontests/generic_views/list.py
@@ -1,7 +1,10 @@
+from __future__ import absolute_import
+
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
-from regressiontests.generic_views.models import Author, Artist
+from .models import Author, Artist
+
class ListViewTests(TestCase):
fixtures = ['generic-views-test-data.json']
diff --git a/tests/regressiontests/generic_views/models.py b/tests/regressiontests/generic_views/models.py
index 5445e24cee..5977258f5f 100644
--- a/tests/regressiontests/generic_views/models.py
+++ b/tests/regressiontests/generic_views/models.py
@@ -1,5 +1,6 @@
from django.db import models
+
class Artist(models.Model):
name = models.CharField(max_length=100)
diff --git a/tests/regressiontests/generic_views/tests.py b/tests/regressiontests/generic_views/tests.py
index a4010aa7c9..d387216d41 100644
--- a/tests/regressiontests/generic_views/tests.py
+++ b/tests/regressiontests/generic_views/tests.py
@@ -1,5 +1,10 @@
-from regressiontests.generic_views.base import ViewTest, TemplateViewTest, RedirectViewTest
-from regressiontests.generic_views.dates import ArchiveIndexViewTests, YearArchiveViewTests, MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests, DateDetailViewTests
-from regressiontests.generic_views.detail import DetailViewTest
-from regressiontests.generic_views.edit import ModelFormMixinTests, CreateViewTests, UpdateViewTests, DeleteViewTests
-from regressiontests.generic_views.list import ListViewTests
+from __future__ import absolute_import
+
+from .base import ViewTest, TemplateViewTest, RedirectViewTest
+from .dates import (ArchiveIndexViewTests, YearArchiveViewTests,
+ MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests,
+ DateDetailViewTests)
+from .detail import DetailViewTest
+from .edit import (ModelFormMixinTests, CreateViewTests, UpdateViewTests,
+ DeleteViewTests)
+from .list import ListViewTests
diff --git a/tests/regressiontests/generic_views/urls.py b/tests/regressiontests/generic_views/urls.py
index c5c63eec25..090ec73c4a 100644
--- a/tests/regressiontests/generic_views/urls.py
+++ b/tests/regressiontests/generic_views/urls.py
@@ -1,8 +1,10 @@
-from django.conf.urls import patterns, url
-from django.views.generic import TemplateView
-from django.views.decorators.cache import cache_page
+from __future__ import absolute_import
-import views
+from django.conf.urls import patterns, url
+from django.views.decorators.cache import cache_page
+from django.views.generic import TemplateView
+
+from . import views
urlpatterns = patterns('',
diff --git a/tests/regressiontests/generic_views/views.py b/tests/regressiontests/generic_views/views.py
index 00d00219a4..5ff9cf0e65 100644
--- a/tests/regressiontests/generic_views/views.py
+++ b/tests/regressiontests/generic_views/views.py
@@ -1,11 +1,13 @@
+from __future__ import absolute_import
+
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
from django.utils.decorators import method_decorator
from django.views import generic
-from regressiontests.generic_views.models import Artist, Author, Book, Page
-from regressiontests.generic_views.forms import AuthorForm
+from .forms import AuthorForm
+from .models import Artist, Author, Book, Page
class CustomTemplateView(generic.TemplateView):
diff --git a/tests/regressiontests/get_or_create_regress/tests.py b/tests/regressiontests/get_or_create_regress/tests.py
index 103e254d4c..92c371b6f8 100644
--- a/tests/regressiontests/get_or_create_regress/tests.py
+++ b/tests/regressiontests/get_or_create_regress/tests.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from models import Author, Publisher
+from .models import Author, Publisher
class GetOrCreateTests(TestCase):
diff --git a/tests/regressiontests/handlers/tests.py b/tests/regressiontests/handlers/tests.py
index 40b0a8375a..59d3d84528 100644
--- a/tests/regressiontests/handlers/tests.py
+++ b/tests/regressiontests/handlers/tests.py
@@ -1,7 +1,7 @@
-from django.utils import unittest
from django.conf import settings
from django.core.handlers.wsgi import WSGIHandler
from django.test import RequestFactory
+from django.utils import unittest
class HandlerTests(unittest.TestCase):
diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py
index 81065564c7..7513c46a8f 100644
--- a/tests/regressiontests/httpwrappers/tests.py
+++ b/tests/regressiontests/httpwrappers/tests.py
@@ -5,6 +5,7 @@ from django.http import (QueryDict, HttpResponse, SimpleCookie, BadHeaderError,
parse_cookie)
from django.utils import unittest
+
class QueryDictTests(unittest.TestCase):
def test_missing_key(self):
q = QueryDict('')
diff --git a/tests/regressiontests/i18n/commands/compilation.py b/tests/regressiontests/i18n/commands/compilation.py
index 44bb2f6ab4..98b4b33356 100644
--- a/tests/regressiontests/i18n/commands/compilation.py
+++ b/tests/regressiontests/i18n/commands/compilation.py
@@ -8,8 +8,8 @@ from django.core.management import CommandError
from django.core.management.commands.compilemessages import compile_messages
from django.test import TestCase
-LOCALE='es_AR'
+LOCALE='es_AR'
class MessageCompilationTests(TestCase):
diff --git a/tests/regressiontests/i18n/commands/extraction.py b/tests/regressiontests/i18n/commands/extraction.py
index 4f476340f2..7d7cdf7485 100644
--- a/tests/regressiontests/i18n/commands/extraction.py
+++ b/tests/regressiontests/i18n/commands/extraction.py
@@ -2,8 +2,10 @@
import os
import re
import shutil
-from django.test import TestCase
+
from django.core import management
+from django.test import TestCase
+
LOCALE='de'
diff --git a/tests/regressiontests/i18n/contenttypes/tests.py b/tests/regressiontests/i18n/contenttypes/tests.py
index eb5c1718fc..79928d9e4f 100644
--- a/tests/regressiontests/i18n/contenttypes/tests.py
+++ b/tests/regressiontests/i18n/contenttypes/tests.py
@@ -3,10 +3,10 @@ from __future__ import with_statement
import os
+from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from django.test.utils import override_settings
from django.utils import translation
-from django.contrib.contenttypes.models import ContentType
class ContentTypeTests(TestCase):
diff --git a/tests/regressiontests/i18n/forms.py b/tests/regressiontests/i18n/forms.py
index 600f252aa5..b2eb74c74c 100644
--- a/tests/regressiontests/i18n/forms.py
+++ b/tests/regressiontests/i18n/forms.py
@@ -1,7 +1,10 @@
+from __future__ import absolute_import
+
from django import forms
from django.forms.extras import SelectDateWidget
-from models import Company
+from .models import Company
+
class I18nForm(forms.Form):
decimal_field = forms.DecimalField(localize=True)
diff --git a/tests/regressiontests/i18n/models.py b/tests/regressiontests/i18n/models.py
index a302769fef..9b92705a20 100644
--- a/tests/regressiontests/i18n/models.py
+++ b/tests/regressiontests/i18n/models.py
@@ -1,7 +1,9 @@
from datetime import datetime
+
from django.db import models
from django.utils.translation import ugettext_lazy as _
+
class TestModel(models.Model):
text = models.CharField(max_length=10, default=_('Anything'))
diff --git a/tests/regressiontests/i18n/test_warnings.py b/tests/regressiontests/i18n/test_warnings.py
index 60dd1a8c6f..8aac89d16c 100644
--- a/tests/regressiontests/i18n/test_warnings.py
+++ b/tests/regressiontests/i18n/test_warnings.py
@@ -1,5 +1,5 @@
-from os.path import join, normpath, abspath, dirname
import warnings
+from os.path import join, normpath, abspath, dirname
import django
from django.conf import settings
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index 68eafbf276..fc69d9cc59 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
+
import datetime
import decimal
import os
@@ -10,24 +11,24 @@ from django.conf import settings
from django.template import Template, Context
from django.test import TestCase, RequestFactory
from django.test.utils import override_settings
+from django.utils import translation
from django.utils.formats import (get_format, date_format, time_format,
localize, localize_input, iter_format_modules, get_format_modules)
from django.utils.importlib import import_module
from django.utils.numberformat import format as nformat
from django.utils.safestring import mark_safe, SafeString, SafeUnicode
-from django.utils import translation
from django.utils.translation import (ugettext, ugettext_lazy, activate,
- deactivate, gettext_lazy, pgettext, npgettext, to_locale,
- get_language_info, get_language, get_language_from_request)
+ deactivate, gettext_lazy, pgettext, npgettext, to_locale,
+ get_language_info, get_language, get_language_from_request)
-from forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm
-from models import Company, TestModel
+from .commands.tests import NoWrapExtractorTests, IgnoredExtractorTests, MessageCompilationTests, PoFileTests, BasicExtractorTests, JavascriptExtractorTests, CopyPluralFormsExtractorTests, SymlinkExtractorTests, ExtractorTests
+from .contenttypes.tests import ContentTypeTests
+from .forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm
+from .models import Company, TestModel
+from .patterns.tests import URLRedirectWithoutTrailingSlashTests, URLTranslationTests, URLDisabledTests, URLTagTests, URLTestCaseBase, URLRedirectWithoutTrailingSlashSettingTests, URLNamespaceTests, URLPrefixTests, URLResponseTests, URLRedirectTests
+from .test_warnings import DeprecationWarningTests
-from commands.tests import *
-from patterns.tests import *
-from contenttypes.tests import *
-from test_warnings import DeprecationWarningTests
here = os.path.dirname(os.path.abspath(__file__))
diff --git a/tests/regressiontests/initial_sql_regress/models.py b/tests/regressiontests/initial_sql_regress/models.py
index 6c7db2f362..76de6d3bcb 100644
--- a/tests/regressiontests/initial_sql_regress/models.py
+++ b/tests/regressiontests/initial_sql_regress/models.py
@@ -4,6 +4,7 @@ Regression tests for initial SQL insertion.
from django.db import models
+
class Simple(models.Model):
name = models.CharField(max_length = 50)
diff --git a/tests/regressiontests/initial_sql_regress/tests.py b/tests/regressiontests/initial_sql_regress/tests.py
index 1e6710be9e..815b75a9bb 100644
--- a/tests/regressiontests/initial_sql_regress/tests.py
+++ b/tests/regressiontests/initial_sql_regress/tests.py
@@ -1,6 +1,6 @@
from django.test import TestCase
-from models import Simple
+from .models import Simple
class InitialSQLTests(TestCase):
diff --git a/tests/regressiontests/inline_formsets/tests.py b/tests/regressiontests/inline_formsets/tests.py
index b47967971a..59187ee6d0 100644
--- a/tests/regressiontests/inline_formsets/tests.py
+++ b/tests/regressiontests/inline_formsets/tests.py
@@ -1,7 +1,9 @@
+from __future__ import absolute_import
+
from django.forms.models import inlineformset_factory
from django.test import TestCase
-from regressiontests.inline_formsets.models import Poet, Poem, School, Parent, Child
+from .models import Poet, Poem, School, Parent, Child
class DeletionTests(TestCase):
diff --git a/tests/regressiontests/introspection/models.py b/tests/regressiontests/introspection/models.py
index ef485e3a3c..da12f6e5cb 100644
--- a/tests/regressiontests/introspection/models.py
+++ b/tests/regressiontests/introspection/models.py
@@ -1,5 +1,6 @@
from django.db import models
+
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
diff --git a/tests/regressiontests/introspection/tests.py b/tests/regressiontests/introspection/tests.py
index fdf30126cd..1835064fcd 100644
--- a/tests/regressiontests/introspection/tests.py
+++ b/tests/regressiontests/introspection/tests.py
@@ -1,8 +1,11 @@
+from __future__ import absolute_import
+
from functools import update_wrapper
+
from django.db import connection
from django.test import TestCase, skipUnlessDBFeature
-from models import Reporter, Article
+from .models import Reporter, Article
#
# The introspection module is optional, so methods tested here might raise
diff --git a/tests/regressiontests/localflavor/au/forms.py b/tests/regressiontests/localflavor/au/forms.py
index e65b92438e..aec00694fe 100644
--- a/tests/regressiontests/localflavor/au/forms.py
+++ b/tests/regressiontests/localflavor/au/forms.py
@@ -1,5 +1,9 @@
+from __future__ import absolute_import
+
from django.forms import ModelForm
-from models import AustralianPlace
+
+from .models import AustralianPlace
+
class AustralianPlaceForm(ModelForm):
""" Form for storing an Australian place. """
diff --git a/tests/regressiontests/localflavor/au/models.py b/tests/regressiontests/localflavor/au/models.py
index 8adfa1f6f5..39061c5bb3 100644
--- a/tests/regressiontests/localflavor/au/models.py
+++ b/tests/regressiontests/localflavor/au/models.py
@@ -1,5 +1,5 @@
-from django.db import models
from django.contrib.localflavor.au.models import AUStateField, AUPostCodeField
+from django.db import models
class AustralianPlace(models.Model):
state = AUStateField(blank=True)
diff --git a/tests/regressiontests/localflavor/au/tests.py b/tests/regressiontests/localflavor/au/tests.py
index bdfaa2b799..de74b1f2b9 100644
--- a/tests/regressiontests/localflavor/au/tests.py
+++ b/tests/regressiontests/localflavor/au/tests.py
@@ -1,10 +1,13 @@
+from __future__ import absolute_import
+
import re
from django.test import SimpleTestCase
from django.contrib.localflavor.au.forms import (AUPostCodeField,
AUPhoneNumberField, AUStateSelect)
-from forms import AustralianPlaceForm
+from .forms import AustralianPlaceForm
+
SELECTED_OPTION_PATTERN = r'