Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit d362c1546f8ad62811e5dee3cf0b43170e6e1c4c 1 parent d5a45d7
@alex alex authored
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
View
7 tests/regressiontests/admin_changelist/admin.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):
View
1  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)
View
11 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):
View
3  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)),
View
4 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):
View
3  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)
View
16 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):
View
9 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):
View
5 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)),
View
3  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)
View
7 tests/regressiontests/admin_ordering/tests.py
@@ -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):
View
1  tests/regressiontests/admin_registration/models.py
@@ -4,6 +4,7 @@
from django.db import models
+
class Person(models.Model):
name = models.CharField(max_length=200)
View
9 tests/regressiontests/admin_registration/tests.py
@@ -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']
View
3  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.
View
7 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)
View
4 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']
View
6 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:
View
1  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:
View
3  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()))
-
+
View
4 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'),
View
1  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
View
1  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
View
2  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 @@ def __unicode__(self):
class Meta:
ordering = ('-pub_date', 'headline')
-
View
4 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
View
1  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
View
8 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.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):
View
8 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
View
18 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):
View
5 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
View
1  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):
View
4 tests/regressiontests/admin_views/models.py
@@ -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):
View
36 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.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 @@ def setUp(self):
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 @@ def tearDown(self):
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):
View
8 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')),
View
7 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.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,
View
6 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)),
View
5 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
View
4 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.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):
View
2  tests/regressiontests/app_loading/tests.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
import copy
import os
import sys
View
3  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):
View
9 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):
View
1  tests/regressiontests/bash_completion/tests.py
@@ -9,6 +9,7 @@
from django.core.management import ManagementUtility
from django.utils import unittest
+
class BashCompletionTests(unittest.TestCase):
"""
Testing the Python level bash completion code.
View
3  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)
View
5 tests/regressiontests/bug639/tests.py
@@ -4,13 +4,16 @@
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):
View
4 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)
View
1  tests/regressiontests/bug8245/models.py
@@ -1,4 +1,5 @@
from django.db import models
+
class Story(models.Model):
title = models.CharField(max_length=10)
View
18 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")
View
4 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):
View
1  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
View
4 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()
View
4 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 @@
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():
View
1  tests/regressiontests/comment_tests/custom_comments/forms.py
@@ -1,4 +1,5 @@
from django import forms
+
class CustomCommentForm(forms.Form):
pass
View
1  tests/regressiontests/comment_tests/custom_comments/models.py
@@ -1,4 +1,5 @@
from django.db import models
+
class CustomComment(models.Model):
pass
View
1  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.")
View
3  tests/regressiontests/comment_tests/models.py
@@ -4,7 +4,7 @@
"""
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 @@ def __str__(self):
class Book(models.Model):
dewey_decimal = models.DecimalField(primary_key=True, decimal_places=2, max_digits=5)
-
View
5 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
View
6 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"""
View
6 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):
View
10 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
View
9 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<pk>\d+$)')
View
4 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):
View
6 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):
View
4 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):
View
8 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):
View
15 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('',
View
2  tests/regressiontests/conditional_processing/models.py
@@ -5,6 +5,7 @@
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 @@
ETAG = 'b4246ffc4f62314ca13147c9d4f76974'
EXPIRED_ETAG = '7fae4cd4b0f81e7d2914700043aa8ed6'
-
class ConditionalGet(TestCase):
urls = 'regressiontests.conditional_processing.urls'
View
4 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),
View
5 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)
View
4 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('',
View
9 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():
View
1  tests/regressiontests/custom_columns_regress/models.py
@@ -8,6 +8,7 @@
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)
View
7 tests/regressiontests/custom_columns_regress/tests.py
@@ -1,7 +1,10 @@
-from django.test import TestCase
+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"""
View
1  tests/regressiontests/custom_managers_regress/models.py
@@ -4,6 +4,7 @@
from django.db import models
+
class RestrictedManager(models.Manager):
"""
A manager that filters out non-public instances.
View
5 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):
View
1  tests/regressiontests/datatypes/models.py
@@ -5,6 +5,7 @@
from django.db import models
+
class Donut(models.Model):
name = models.CharField(max_length=100)
is_frosted = models.BooleanField(default=False)
View
5 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):
View
4 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):
View
10 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):
View
4 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):
View
1  tests/regressiontests/defer_regress/models.py
@@ -4,6 +4,7 @@
from django.db import models
+
class Item(models.Model):
name = models.CharField(max_length=15)
text = models.TextField(default="xyzzy")
View
6 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.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):
View
4 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)
View
8 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
View
6 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 *
View
3  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:
View
1  tests/regressiontests/expressions_regress/models.py
@@ -3,6 +3,7 @@
"""
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')
View
14 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 @@ def setUp(self):
# 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 @@ def test_delta_subtract(self):
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])
View
1  tests/regressiontests/extra_regress/models.py
@@ -4,6 +4,7 @@
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)
View
10 tests/regressiontests/extra_regress/tests.py
@@ -1,11 +1,13 @@
-from django.test import TestCase
+from __future__ import absolute_import
-from django.utils.datastructures import SortedDict
+import datetime
from django.contrib.auth.models import User
-from regressiontests.extra_regress.models import TestObject, Order, RevisionableModel
+from django.test import TestCase
+from django.utils.datastructures import SortedDict
+
+from .models import TestObject, Order, RevisionableModel
-import datetime
class ExtraRegressTests(TestCase):
View
2  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
View
4 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')
View
9 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.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'
View
9 tests/regressiontests/file_uploads/uploadhandler.py
@@ -4,24 +4,25 @@
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
View
6 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),
View
11 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):
"""
View
4 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):
View
17 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 @@
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 = []
View
2  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()
View
26 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 *
View
7 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):
View
13 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)
View
1  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
View
2  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):
View
8 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):
View
1  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 *
Please sign in to comment.
Something went wrong with that request. Please try again.