Permalink
Browse files

Convert much of the regression tests to use absolute imports. There's…

… still work to be done though.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16976 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent d5a45d7 commit d362c1546f8ad62811e5dee3cf0b43170e6e1c4c @alex alex committed Oct 13, 2011
Showing with 389 additions and 213 deletions.
  1. +5 −2 tests/regressiontests/admin_changelist/admin.py
  2. +1 −0 tests/regressiontests/admin_changelist/models.py
  3. +5 −6 tests/regressiontests/admin_changelist/tests.py
  4. +2 −1 tests/regressiontests/admin_changelist/urls.py
  5. +3 −1 tests/regressiontests/admin_custom_urls/tests.py
  6. +2 −1 tests/regressiontests/admin_filters/models.py
  7. +9 −7 tests/regressiontests/admin_filters/tests.py
  8. +5 −4 tests/regressiontests/admin_inlines/tests.py
  9. +4 −1 tests/regressiontests/admin_inlines/urls.py
  10. +2 −1 tests/regressiontests/admin_ordering/models.py
  11. +5 −2 tests/regressiontests/admin_ordering/tests.py
  12. +1 −0 tests/regressiontests/admin_registration/models.py
  13. +6 −3 tests/regressiontests/admin_registration/tests.py
  14. +2 −1 tests/regressiontests/admin_scripts/app_with_import/models.py
  15. +6 −1 tests/regressiontests/admin_scripts/complex_app/admin/foo.py
  16. +2 −2 tests/regressiontests/admin_scripts/complex_app/models/__init__.py
  17. +5 −1 tests/regressiontests/admin_scripts/complex_app/models/bar.py
  18. +1 −0 tests/regressiontests/admin_scripts/complex_app/models/foo.py
  19. +2 −1 tests/regressiontests/admin_scripts/management/commands/app_command.py
  20. +3 −1 tests/regressiontests/admin_scripts/management/commands/base_command.py
  21. +1 −0 tests/regressiontests/admin_scripts/management/commands/label_command.py
  22. +1 −0 tests/regressiontests/admin_scripts/management/commands/noargs_command.py
  23. +1 −1 tests/regressiontests/admin_scripts/models.py
  24. +3 −1 tests/regressiontests/admin_scripts/simple_app/models.py
  25. +1 −0 tests/regressiontests/admin_util/models.py
  26. +5 −3 tests/regressiontests/admin_util/tests.py
  27. +5 −3 tests/regressiontests/admin_validation/tests.py
  28. +16 −2 tests/regressiontests/admin_views/admin.py
  29. +4 −1 tests/regressiontests/admin_views/customadmin.py
  30. +1 −0 tests/regressiontests/admin_views/forms.py
  31. +2 −2 tests/regressiontests/admin_views/models.py
  32. +17 −19 tests/regressiontests/admin_views/tests.py
  33. +5 −3 tests/regressiontests/admin_views/urls.py
  34. +4 −3 tests/regressiontests/admin_widgets/tests.py
  35. +5 −1 tests/regressiontests/admin_widgets/urls.py
  36. +4 −1 tests/regressiontests/admin_widgets/widgetadmin.py
  37. +3 −1 tests/regressiontests/aggregation_regress/tests.py
  38. +2 −0 tests/regressiontests/app_loading/tests.py
  39. +1 −2 tests/regressiontests/backends/models.py
  40. +6 −3 tests/regressiontests/backends/tests.py
  41. +1 −0 tests/regressiontests/bash_completion/tests.py
  42. +2 −1 tests/regressiontests/bug639/models.py
  43. +4 −1 tests/regressiontests/bug639/tests.py
  44. +3 −1 tests/regressiontests/bug8245/admin.py
  45. +1 −0 tests/regressiontests/bug8245/models.py
  46. +6 −12 tests/regressiontests/bug8245/tests.py
  47. +2 −2 tests/regressiontests/bulk_create/tests.py
  48. +1 −0 tests/regressiontests/cache/liberal_backend.py
  49. +3 −1 tests/regressiontests/cache/models.py
  50. +2 −2 tests/regressiontests/cache/tests.py
  51. +1 −0 tests/regressiontests/comment_tests/custom_comments/forms.py
  52. +1 −0 tests/regressiontests/comment_tests/custom_comments/models.py
  53. +1 −0 tests/regressiontests/comment_tests/custom_comments/views.py
  54. +1 −2 tests/regressiontests/comment_tests/models.py
  55. +4 −1 tests/regressiontests/comment_tests/tests/__init__.py
  56. +5 −1 tests/regressiontests/comment_tests/tests/app_api_tests.py
  57. +4 −2 tests/regressiontests/comment_tests/tests/comment_form_tests.py
  58. +6 −4 tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
  59. +7 −2 tests/regressiontests/comment_tests/tests/comment_view_tests.py
  60. +3 −1 tests/regressiontests/comment_tests/tests/feed_tests.py
  61. +4 −2 tests/regressiontests/comment_tests/tests/model_tests.py
  62. +3 −1 tests/regressiontests/comment_tests/tests/moderation_view_tests.py
  63. +5 −3 tests/regressiontests/comment_tests/tests/templatetag_tests.py
  64. +10 −5 tests/regressiontests/comment_tests/urls.py
  65. +1 −1 tests/regressiontests/conditional_processing/models.py
  66. +3 −1 tests/regressiontests/conditional_processing/urls.py
  67. +4 −1 tests/regressiontests/conditional_processing/views.py
  68. +3 −1 tests/regressiontests/context_processors/urls.py
  69. +5 −4 tests/regressiontests/csrf_tests/tests.py
  70. +1 −0 tests/regressiontests/custom_columns_regress/models.py
  71. +5 −2 tests/regressiontests/custom_columns_regress/tests.py
  72. +1 −0 tests/regressiontests/custom_managers_regress/models.py
  73. +4 −1 tests/regressiontests/custom_managers_regress/tests.py
  74. +1 −0 tests/regressiontests/datatypes/models.py
  75. +4 −1 tests/regressiontests/datatypes/tests.py
  76. +3 −1 tests/regressiontests/dates/tests.py
  77. +5 −5 tests/regressiontests/decorators/tests.py
  78. +3 −1 tests/regressiontests/defaultfilters/tests.py
  79. +1 −0 tests/regressiontests/defer_regress/models.py
  80. +4 −2 tests/regressiontests/defer_regress/tests.py
  81. +2 −2 tests/regressiontests/delete_regress/models.py
  82. +5 −3 tests/regressiontests/delete_regress/tests.py
  83. +4 −2 tests/regressiontests/dispatch/tests/__init__.py
  84. +2 −1 tests/regressiontests/dispatch/tests/test_dispatcher.py
  85. +1 −0 tests/regressiontests/expressions_regress/models.py
  86. +8 −6 tests/regressiontests/expressions_regress/tests.py
  87. +1 −0 tests/regressiontests/extra_regress/models.py
  88. +6 −4 tests/regressiontests/extra_regress/tests.py
  89. +1 −1 tests/regressiontests/file_storage/tests.py
  90. +3 −1 tests/regressiontests/file_uploads/models.py
  91. +5 −4 tests/regressiontests/file_uploads/tests.py
  92. +5 −4 tests/regressiontests/file_uploads/uploadhandler.py
  93. +5 −1 tests/regressiontests/file_uploads/urls.py
  94. +8 −3 tests/regressiontests/file_uploads/views.py
  95. +3 −1 tests/regressiontests/fixtures_regress/models.py
  96. +7 −10 tests/regressiontests/fixtures_regress/tests.py
  97. +1 −1 tests/regressiontests/forms/models.py
  98. +14 −12 tests/regressiontests/forms/tests/__init__.py
  99. +5 −2 tests/regressiontests/forms/tests/error_messages.py
  100. +8 −5 tests/regressiontests/forms/tests/extra.py
  101. +1 −0 tests/regressiontests/forms/tests/forms.py
  102. +1 −1 tests/regressiontests/forms/tests/media.py
  103. +6 −2 tests/regressiontests/forms/tests/models.py
  104. +1 −0 tests/regressiontests/forms/tests/widgets.py
@@ -1,9 +1,12 @@
-from django.core.paginator import Paginator
+from __future__ import absolute_import
+
from django.contrib import admin
+from django.core.paginator import Paginator
-from models import (Child, Parent, Genre, Band, Musician, Group, Quartet,
+from .models import (Child, Parent, Genre, Band, Musician, Group, Quartet,
Membership, ChordsMusician, ChordsBand, Invitation)
+
site = admin.AdminSite(name="admin")
class CustomPaginator(Paginator):
@@ -1,5 +1,6 @@
from django.db import models
+
class Parent(models.Model):
name = models.CharField(max_length=128)
@@ -1,19 +1,18 @@
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
from django.contrib import admin
from django.contrib.admin.options import IncorrectLookupParameters
from django.contrib.admin.views.main import ChangeList, SEARCH_VAR, ALL_VAR
+from django.contrib.auth.models import User
from django.template import Context, Template
from django.test import TestCase
from django.test.client import RequestFactory
-from django.contrib.auth.models import User
-from models import (Child, Parent, Genre, Band, Musician, Group, Quartet,
- Membership, ChordsMusician, ChordsBand, Invitation)
-
-from admin import (ChildAdmin, QuartetAdmin, BandAdmin, ChordsBandAdmin,
+from .admin import (ChildAdmin, QuartetAdmin, BandAdmin, ChordsBandAdmin,
GroupAdmin, ParentAdmin, DynamicListDisplayChildAdmin, CustomPaginationAdmin,
FilteredChildAdmin, CustomPaginator, site as custom_site)
+from .models import (Child, Parent, Genre, Band, Musician, Group, Quartet,
+ Membership, ChordsMusician, ChordsBand, Invitation)
class ChangeListTests(TestCase):
@@ -1,6 +1,7 @@
from django.conf.urls import patterns, include
-import admin
+from . import admin
+
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from django.core.urlresolvers import reverse
from django.template.response import TemplateResponse
from django.test import TestCase
-from models import Action
+from .models import Action
class AdminCustomUrlsTest(TestCase):
@@ -1,5 +1,6 @@
-from django.db import models
from django.contrib.auth.models import User
+from django.db import models
+
class Book(models.Model):
title = models.CharField(max_length=50)
@@ -1,21 +1,23 @@
+from __future__ import absolute_import
+
import datetime
+from django.contrib.admin import (site, ModelAdmin, SimpleListFilter,
+ BooleanFieldListFilter)
from django.contrib.admin.options import IncorrectLookupParameters
+from django.contrib.admin.views.main import ChangeList
+from django.contrib.auth.admin import UserAdmin
+from django.contrib.auth.models import User
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, RequestFactory
from django.utils.encoding import force_unicode
-from django.contrib.auth.admin import UserAdmin
-from django.contrib.auth.models import User
-from django.contrib.admin.views.main import ChangeList
-from django.contrib.admin import (site, ModelAdmin, SimpleListFilter,
- BooleanFieldListFilter)
-from models import Book
+from .models import Book
+
def select_by(dictlist, key, value):
return [x for x in dictlist if x[key] == value][0]
-
class DecadeListFilter(SimpleListFilter):
def lookups(self, request, model_admin):
@@ -1,13 +1,14 @@
+from __future__ import absolute_import
+
from django.contrib.admin.helpers import InlineAdminForm
from django.contrib.auth.models import User, Permission
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
# local test models
-from models import (Holder, Inner, Holder2, Inner2, Holder3,
- Inner3, Person, OutfitItem, Fashionista, Teacher, Parent, Child,
- Author, Book)
-from admin import InnerInline
+from .admin import InnerInline
+from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person,
+ OutfitItem, Fashionista, Teacher, Parent, Child, Author, Book)
class TestInline(TestCase):
@@ -1,6 +1,9 @@
+from __future__ import absolute_import
+
from django.conf.urls import patterns, include
-import admin
+from . import admin
+
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
@@ -1,6 +1,7 @@
# coding: utf-8
-from django.db import models
from django.contrib import admin
+from django.db import models
+
class Band(models.Model):
name = models.CharField(max_length=100)
@@ -1,8 +1,11 @@
+from __future__ import absolute_import
+
from django.test import TestCase, RequestFactory
-from django.contrib.auth.models import User
from django.contrib.admin.options import ModelAdmin
+from django.contrib.auth.models import User
-from models import Band, Song, SongInlineDefaultOrdering, SongInlineNewOrdering, DynOrderingBandAdmin
+from .models import (Band, Song, SongInlineDefaultOrdering,
+ SongInlineNewOrdering, DynOrderingBandAdmin)
class MockRequest(object):
@@ -4,6 +4,7 @@
from django.db import models
+
class Person(models.Model):
name = models.CharField(max_length=200)
@@ -1,8 +1,11 @@
-from django.test import TestCase
-from django.core.exceptions import ImproperlyConfigured
+from __future__ import absolute_import
+
from django.contrib import admin
+from django.core.exceptions import ImproperlyConfigured
+from django.test import TestCase
+
+from .models import Person, Place, Location
-from models import Person, Place, Location
class NameAdmin(admin.ModelAdmin):
list_display = ['name']
@@ -1,5 +1,6 @@
-from django.contrib.comments.models import Comment
from django.db import models
+from django.contrib.comments.models import Comment
+
# Regression for #13368. This is an example of a model
# that imports a class that has an abstract base class.
@@ -1,3 +1,8 @@
+from __future__ import absolute_import
+
from django.contrib import admin
-from admin_scripts.complex_app.models.foo import Foo
+
+from ..models.foo import Foo
+
+
admin.site.register(Foo)
@@ -1,4 +1,4 @@
-from admin_scripts.complex_app.models.bar import Bar
-from admin_scripts.complex_app.models.foo import Foo
+from .bar import Bar
+from .foo import Foo
__all__ = ['Foo', 'Bar']
@@ -1,6 +1,10 @@
+from __future__ import absolute_import
+
from django.db import models
-from admin_scripts.complex_app.admin import foo
+from ..admin import foo
+
+
class Bar(models.Model):
name = models.CharField(max_length=5)
class Meta:
@@ -1,5 +1,6 @@
from django.db import models
+
class Foo(models.Model):
name = models.CharField(max_length=5)
class Meta:
@@ -1,10 +1,11 @@
from django.core.management.base import AppCommand
+
class Command(AppCommand):
help = 'Test Application-based commands'
requires_model_validation = False
args = '[appname ...]'
def handle_app(self, app, **options):
print 'EXECUTE:AppCommand app=%s, options=%s' % (app, sorted(options.items()))
-
+
@@ -1,6 +1,8 @@
-from django.core.management.base import BaseCommand
from optparse import make_option
+from django.core.management.base import BaseCommand
+
+
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--option_a','-a', action='store', dest='option_a', default='1'),
@@ -1,5 +1,6 @@
from django.core.management.base import LabelCommand
+
class Command(LabelCommand):
help = "Test Label-based commands"
requires_model_validation = False
@@ -1,5 +1,6 @@
from django.core.management.base import NoArgsCommand
+
class Command(NoArgsCommand):
help = "Test No-args commands"
requires_model_validation = False
@@ -1,5 +1,6 @@
from django.db import models
+
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
@@ -9,4 +10,3 @@ def __unicode__(self):
class Meta:
ordering = ('-pub_date', 'headline')
-
@@ -1 +1,3 @@
-from admin_scripts.complex_app.models.bar import Bar
+from __future__ import absolute_import
+
+from ..complex_app.models.bar import Bar
@@ -1,5 +1,6 @@
from django.db import models
+
class Article(models.Model):
"""
A simple Article model for testing
@@ -1,17 +1,19 @@
+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
from django.test import TestCase
from django.utils import unittest
from django.utils.formats import localize
-from models import Article, Count, Event, Location
+from .models import Article, Count, Event, Location
class NestedObjectsTests(TestCase):
@@ -1,11 +1,13 @@
+from __future__ import absolute_import
+
from django import forms
+from django.contrib import admin
+from django.contrib.admin.validation import validate, validate_inline
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
-from django.contrib import admin
-from django.contrib.admin.validation import validate, validate_inline
+from .models import Song, Book, Album, TwoAlbumFKAndAnE, State, City
-from models import Song, Book, Album, TwoAlbumFKAndAnE, State, City
class SongForm(forms.ModelForm):
pass
@@ -1,14 +1,28 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
import datetime
import tempfile
import os
+from django import forms
from django.contrib import admin
from django.contrib.admin.views.main import ChangeList
-from django.forms.models import BaseModelFormSet
+from django.core.files.storage import FileSystemStorage
from django.core.mail import EmailMessage
+from django.db import models
+from django.forms.models import BaseModelFormSet
-from models import *
+from .models import (Article, Chapter, Account, Media, Child, Parent, Picture,
+ Widget, DooHickey, Grommet, Whatsit, FancyDoodad, Category, Link,
+ PrePopulatedPost, PrePopulatedSubPost, CustomArticle, Section,
+ ModelWithStringPrimaryKey, Color, Thing, Actor, Inquisition, Sketch, Person,
+ Persona, Subscriber, ExternalSubscriber, OldSubscriber, Vodcast, EmptyModel,
+ Fabric, Gallery, Language, Recommendation, Recommender, Collector, Post,
+ Gadget, Villain, SuperVillain, Plot, PlotDetails, CyclicOne, CyclicTwo,
+ WorkHour, Reservation, FoodDelivery, RowLevelChangePermissionModel, Paper,
+ CoverLetter, Story, OtherStory, Book, Promo, ChapterXtra1, Pizza, Topping,
+ Album, Question, Answer, ComplexSortedPerson)
def callable_year(dt_value):
@@ -1,11 +1,14 @@
"""
A second, custom AdminSite -- see tests.CustomAdminSiteTests.
"""
+from __future__ import absolute_import
+
from django.conf.urls import patterns
from django.contrib import admin
from django.http import HttpResponse
-import models, forms, admin as base_admin
+from . import models, forms, admin as base_admin
+
class Admin2(admin.AdminSite):
login_form = forms.CustomAdminAuthenticationForm
@@ -1,6 +1,7 @@
from django import forms
from django.contrib.admin.forms import AdminAuthenticationForm
+
class CustomAdminAuthenticationForm(AdminAuthenticationForm):
def clean_username(self):
@@ -3,12 +3,12 @@
import 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):
Oops, something went wrong.

0 comments on commit d362c15

Please sign in to comment.