Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Convert all modeltests to use absolute imports, rather than relative …

…ones.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16975 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d5a45d79fe03cad93ab5761860e9bb6fc1db4c86 1 parent 99512d3
@alex alex authored
Showing with 378 additions and 185 deletions.
  1. +3 −1 tests/modeltests/aggregation/tests.py
  2. +1 −0  tests/modeltests/basic/models.py
  3. +3 −1 tests/modeltests/basic/tests.py
  4. +1 −0  tests/modeltests/choices/models.py
  5. +5 −3 tests/modeltests/choices/tests.py
  6. +1 −0  tests/modeltests/custom_columns/models.py
  7. +3 −1 tests/modeltests/custom_columns/tests.py
  8. +3 −1 tests/modeltests/custom_managers/tests.py
  9. +3 −1 tests/modeltests/custom_methods/models.py
  10. +3 −1 tests/modeltests/custom_methods/tests.py
  11. +4 −1 tests/modeltests/custom_pk/models.py
  12. +3 −1 tests/modeltests/custom_pk/tests.py
  13. +3 −1 tests/modeltests/defer/tests.py
  14. +3 −1 tests/modeltests/delete/tests.py
  15. +1 −0  tests/modeltests/empty/no_models/tests.py
  16. +2 −2 tests/modeltests/empty/tests.py
  17. +1 −0  tests/modeltests/expressions/models.py
  18. +3 −1 tests/modeltests/expressions/tests.py
  19. +3 −1 tests/modeltests/field_defaults/models.py
  20. +3 −1 tests/modeltests/field_defaults/tests.py
  21. +1 −0  tests/modeltests/field_subclassing/fields.py
  22. +3 −1 tests/modeltests/field_subclassing/models.py
  23. +4 −2 tests/modeltests/field_subclassing/tests.py
  24. +2 −2 tests/modeltests/files/tests.py
  25. +1 −1  tests/modeltests/fixtures/models.py
  26. +3 −1 tests/modeltests/fixtures/tests.py
  27. +1 −0  tests/modeltests/fixtures_model_package/models/__init__.py
  28. +1 −1  tests/modeltests/fixtures_model_package/tests.py
  29. +1 −0  tests/modeltests/force_insert_update/models.py
  30. +3 −1 tests/modeltests/force_insert_update/tests.py
  31. +3 −1 tests/modeltests/generic_relations/tests.py
  32. +1 −0  tests/modeltests/get_latest/models.py
  33. +3 −1 tests/modeltests/get_latest/tests.py
  34. +1 −0  tests/modeltests/get_object_or_404/models.py
  35. +3 −1 tests/modeltests/get_object_or_404/tests.py
  36. +1 −0  tests/modeltests/get_or_create/models.py
  37. +3 −1 tests/modeltests/get_or_create/tests.py
  38. +1 −0  tests/modeltests/invalid_models/invalid_models/models.py
  39. +2 −2 tests/modeltests/invalid_models/tests.py
  40. +1 −0  tests/modeltests/lookup/models.py
  41. +6 −2 tests/modeltests/lookup/tests.py
  42. +3 −2 tests/modeltests/m2m_and_m2o/models.py
  43. +9 −7 tests/modeltests/m2m_and_m2o/tests.py
  44. +1 −0  tests/modeltests/m2m_intermediary/models.py
  45. +3 −1 tests/modeltests/m2m_intermediary/tests.py
  46. +1 −0  tests/modeltests/m2m_multiple/models.py
  47. +3 −1 tests/modeltests/m2m_multiple/tests.py
  48. +7 −5 tests/modeltests/m2m_recursive/tests.py
  49. +3 −1 tests/modeltests/m2m_signals/tests.py
  50. +3 −1 tests/modeltests/m2m_through/models.py
  51. +3 −1 tests/modeltests/m2m_through/tests.py
  52. +1 −0  tests/modeltests/m2o_recursive/models.py
  53. +5 −1 tests/modeltests/m2o_recursive/tests.py
  54. +1 −0  tests/modeltests/many_to_many/models.py
  55. +5 −1 tests/modeltests/many_to_many/tests.py
  56. +1 −0  tests/modeltests/many_to_one/models.py
  57. +4 −2 tests/modeltests/many_to_one/tests.py
  58. +1 −0  tests/modeltests/many_to_one_null/models.py
  59. +3 −2 tests/modeltests/many_to_one_null/tests.py
  60. +2 −1  tests/modeltests/model_forms/models.py
  61. +8 −9 tests/modeltests/model_forms/tests.py
  62. +2 −0  tests/modeltests/model_formsets/models.py
  63. +4 −2 tests/modeltests/model_formsets/tests.py
  64. +3 −1 tests/modeltests/model_inheritance/tests.py
  65. +4 −1 tests/modeltests/model_inheritance_same_model_name/models.py
  66. +5 −1 tests/modeltests/model_inheritance_same_model_name/tests.py
  67. +4 −2 tests/modeltests/model_package/models/__init__.py
  68. +2 −1  tests/modeltests/model_package/models/article.py
  69. +1 −0  tests/modeltests/model_package/models/publication.py
  70. +4 −2 tests/modeltests/model_package/tests.py
  71. +5 −1 tests/modeltests/mutually_referential/tests.py
  72. +1 −0  tests/modeltests/one_to_one/models.py
  73. +6 −2 tests/modeltests/one_to_one/tests.py
  74. +1 −0  tests/modeltests/or_lookups/models.py
  75. +3 −1 tests/modeltests/or_lookups/tests.py
  76. +10 −8 tests/modeltests/order_with_respect_to/tests.py
  77. +3 −1 tests/modeltests/ordering/tests.py
  78. +16 −14 tests/modeltests/pagination/tests.py
  79. +1 −1  tests/modeltests/prefetch_related/models.py
  80. +4 −6 tests/modeltests/prefetch_related/tests.py
  81. +1 −0  tests/modeltests/properties/models.py
  82. +5 −1 tests/modeltests/properties/tests.py
  83. +4 −0 tests/modeltests/proxy_model_inheritance/app1/models.py
  84. +1 −0  tests/modeltests/proxy_model_inheritance/app2/models.py
  85. +5 −3 tests/modeltests/proxy_model_inheritance/tests.py
  86. +10 −9 tests/modeltests/proxy_models/tests.py
  87. +1 −0  tests/modeltests/raw_query/models.py
  88. +3 −1 tests/modeltests/raw_query/tests.py
  89. +1 −0  tests/modeltests/reserved_names/models.py
  90. +4 −1 tests/modeltests/reserved_names/tests.py
  91. +1 −0  tests/modeltests/reverse_lookup/models.py
  92. +5 −2 tests/modeltests/reverse_lookup/tests.py
  93. +3 −1 tests/modeltests/save_delete_hooks/tests.py
  94. +1 −0  tests/modeltests/select_for_update/models.py
  95. +5 −2 tests/modeltests/select_for_update/tests.py
  96. +3 −1 tests/modeltests/select_related/tests.py
  97. +1 −0  tests/modeltests/serializers/models.py
  98. +5 −4 tests/modeltests/serializers/tests.py
  99. +3 −1 tests/modeltests/signals/tests.py
  100. +1 −0  tests/modeltests/str/models.py
  101. +4 −1 tests/modeltests/str/tests.py
  102. +3 −1 tests/modeltests/test_client/models.py
  103. +4 −3 tests/modeltests/test_client/tests.py
  104. +5 −1 tests/modeltests/test_client/urls.py
  105. +5 −4 tests/modeltests/test_client/views.py
  106. +1 −0  tests/modeltests/transactions/models.py
  107. +2 −2 tests/modeltests/transactions/tests.py
  108. +6 −2 tests/modeltests/unmanaged_models/tests.py
  109. +1 −0  tests/modeltests/update/models.py
  110. +3 −1 tests/modeltests/update/tests.py
  111. +2 −0  tests/modeltests/user_commands/management/commands/dance.py
  112. +2 −1  tests/modeltests/user_commands/tests.py
  113. +9 −12 tests/modeltests/validation/__init__.py
  114. +1 −0  tests/modeltests/validation/models.py
  115. +4 −2 tests/modeltests/validation/test_custom_messages.py
  116. +1 −1  tests/modeltests/validation/test_error_messages.py
  117. +4 −3 tests/modeltests/validation/test_unique.py
  118. +11 −9 tests/modeltests/validation/tests.py
  119. +4 −2 tests/modeltests/validation/validators.py
View
4 tests/modeltests/aggregation/tests.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
import datetime
from decimal import Decimal
from django.db.models import Avg, Sum, Count, Max, Min
from django.test import TestCase, Approximate
-from models import Author, Publisher, Book, Store
+from .models import Author, Publisher, Book, Store
class BaseAggregateTestCase(TestCase):
View
1  tests/modeltests/basic/models.py
@@ -6,6 +6,7 @@
"""
from django.db import models
+
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
View
4 tests/modeltests/basic/tests.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
from datetime import datetime
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields import FieldDoesNotExist
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
-from models import Article
+from .models import Article
class ModelTest(TestCase):
View
1  tests/modeltests/choices/models.py
@@ -11,6 +11,7 @@
from django.db import models
+
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
View
8 tests/modeltests/choices/tests.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from models import Person
+from .models import Person
class ChoicesTests(TestCase):
@@ -9,10 +11,10 @@ def test_display(self):
s = Person.objects.create(name='Sara', gender='F')
self.assertEqual(a.gender, 'M')
self.assertEqual(s.gender, 'F')
-
+
self.assertEqual(a.get_gender_display(), 'Male')
self.assertEqual(s.get_gender_display(), 'Female')
-
+
# If the value for the field doesn't correspond to a valid choice,
# the value itself is provided as a display value.
a.gender = ''
View
1  tests/modeltests/custom_columns/models.py
@@ -17,6 +17,7 @@
from django.db import models
+
class Author(models.Model):
first_name = models.CharField(max_length=30, db_column='firstname')
last_name = models.CharField(max_length=30, db_column='last')
View
4 tests/modeltests/custom_columns/tests.py
@@ -1,7 +1,9 @@
+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
class CustomColumnsTests(TestCase):
View
4 tests/modeltests/custom_managers/tests.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from models import Person, Book, Car, PersonManager, PublishedBookManager
+from .models import Person, Book, Car, PersonManager, PublishedBookManager
class CustomManagerTests(TestCase):
View
4 tests/modeltests/custom_methods/models.py
@@ -4,9 +4,11 @@
Any method you add to a model will be available to instances.
"""
-from django.db import models
import datetime
+from django.db import models
+
+
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
View
4 tests/modeltests/custom_methods/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from datetime import date
from django.test import TestCase
-from models import Article
+from .models import Article
class MethodsTests(TestCase):
View
5 tests/modeltests/custom_pk/models.py
@@ -6,9 +6,12 @@
this behavior by explicitly adding ``primary_key=True`` to a field.
"""
+from __future__ import absolute_import
+
from django.db import models
-from fields import MyAutoField
+from .fields import MyAutoField
+
class Employee(models.Model):
employee_code = models.IntegerField(primary_key=True, db_column = 'code')
View
4 tests/modeltests/custom_pk/tests.py
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from django.db import transaction, IntegrityError
from django.test import TestCase, skipIfDBFeature
-from models import Employee, Business, Bar, Foo
+from .models import Employee, Business, Bar, Foo
class CustomPKTests(TestCase):
View
4 tests/modeltests/defer/tests.py
@@ -1,7 +1,9 @@
+from __future__ import absolute_import
+
from django.db.models.query_utils import DeferredAttribute
from django.test import TestCase
-from models import Secondary, Primary, Child, BigChild
+from .models import Secondary, Primary, Child, BigChild
class DeferTests(TestCase):
View
4 tests/modeltests/delete/tests.py
@@ -1,7 +1,9 @@
+from __future__ import absolute_import
+
from django.db import models, IntegrityError
from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
-from modeltests.delete.models import (R, RChild, S, T, U, A, M, MR, MRNull,
+from .models import (R, RChild, S, T, U, A, M, MR, MRNull,
create_a, get_default_r, User, Avatar, HiddenUser, HiddenUserProfile)
View
1  tests/modeltests/empty/no_models/tests.py
@@ -1,5 +1,6 @@
from django.test import TestCase
+
class NoModelTests(TestCase):
""" A placeholder test case. See modeltests.empty.tests for more info. """
pass
View
4 tests/modeltests/empty/tests.py
@@ -1,4 +1,4 @@
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
@@ -6,7 +6,7 @@
from django.test import TestCase
from django.test.utils import override_settings
-from models import Empty
+from .models import Empty
class EmptyModelTests(TestCase):
View
1  tests/modeltests/expressions/models.py
@@ -4,6 +4,7 @@
from django.db import models
+
class Employee(models.Model):
firstname = models.CharField(max_length=50)
lastname = models.CharField(max_length=50)
View
4 tests/modeltests/expressions/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from django.core.exceptions import FieldError
from django.db.models import F
from django.test import TestCase
-from models import Company, Employee
+from .models import Company, Employee
class ExpressionsTests(TestCase):
View
4 tests/modeltests/field_defaults/models.py
@@ -10,9 +10,11 @@
field.
"""
-from django.db import models
from datetime import datetime
+from django.db import models
+
+
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField(default=datetime.now)
View
4 tests/modeltests/field_defaults/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from datetime import datetime
from django.test import TestCase
-from models import Article
+from .models import Article
class DefaultTests(TestCase):
View
1  tests/modeltests/field_subclassing/fields.py
@@ -2,6 +2,7 @@
from django.utils import simplejson as json
from django.utils.encoding import force_unicode
+
class Small(object):
"""
A simple class to show that non-trivial Python objects can be used as
View
4 tests/modeltests/field_subclassing/models.py
@@ -2,10 +2,12 @@
Tests for field subclassing.
"""
+from __future__ import absolute_import
+
from django.db import models
from django.utils.encoding import force_unicode
-from fields import SmallField, SmallerField, JSONField
+from .fields import SmallField, SmallerField, JSONField
class MyModel(models.Model):
View
6 tests/modeltests/field_subclassing/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from django.core import serializers
from django.test import TestCase
-from fields import Small
-from models import DataModel, MyModel, OtherModel
+from .fields import Small
+from .models import DataModel, MyModel, OtherModel
class CustomField(TestCase):
View
4 tests/modeltests/files/tests.py
@@ -1,4 +1,4 @@
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
import shutil
import tempfile
@@ -9,7 +9,7 @@
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase
-from models import Storage, temp_storage, temp_storage_location
+from .models import Storage, temp_storage, temp_storage_location
class FileTests(TestCase):
View
2  tests/modeltests/fixtures/models.py
@@ -8,10 +8,10 @@
``FIXTURE_DIRS`` setting.
"""
-from django.db import models
from django.contrib.auth.models import Permission
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
+from django.db import models
class Category(models.Model):
View
4 tests/modeltests/fixtures/tests.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
import StringIO
from django.contrib.sites.models import Site
from django.core import management
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
-from models import Article, Book, Spy, Tag, Visa
+from .models import Article, Book, Spy, Tag, Visa
class TestCaseFixtureLoadingTests(TestCase):
View
1  tests/modeltests/fixtures_model_package/models/__init__.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()
View
2  tests/modeltests/fixtures_model_package/tests.py
@@ -1,7 +1,7 @@
from django.core import management
from django.test import TestCase
-from models import Article
+from .models import Article
class SampleTestCase(TestCase):
View
1  tests/modeltests/force_insert_update/models.py
@@ -4,6 +4,7 @@
"""
from django.db import models
+
class Counter(models.Model):
name = models.CharField(max_length = 10)
value = models.IntegerField()
View
4 tests/modeltests/force_insert_update/tests.py
@@ -1,7 +1,9 @@
+from __future__ import absolute_import
+
from django.db import transaction, IntegrityError, DatabaseError
from django.test import TestCase
-from models import Counter, WithCustomPK
+from .models import Counter, WithCustomPK
class ForceTests(TestCase):
View
4 tests/modeltests/generic_relations/tests.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
from django import forms
from django.contrib.contenttypes.generic import generic_inlineformset_factory
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
-from models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
+from .models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
Vegetable, Mineral, Gecko)
View
1  tests/modeltests/get_latest/models.py
@@ -10,6 +10,7 @@
from django.db import models
+
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
View
4 tests/modeltests/get_latest/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from datetime import datetime
from django.test import TestCase
-from models import Article, Person
+from .models import Article, Person
class LatestTests(TestCase):
View
1  tests/modeltests/get_object_or_404/models.py
@@ -12,6 +12,7 @@
from django.db import models
+
class Author(models.Model):
name = models.CharField(max_length=50)
View
4 tests/modeltests/get_object_or_404/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from django.http import Http404
from django.shortcuts import get_object_or_404, get_list_or_404
from django.test import TestCase
-from models import Author, Article
+from .models import Author, Article
class GetObjectOr404Tests(TestCase):
View
1  tests/modeltests/get_or_create/models.py
@@ -8,6 +8,7 @@
from django.db import models
+
class Person(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
View
4 tests/modeltests/get_or_create/tests.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
from datetime import date
from django.db import IntegrityError
from django.test import TestCase
-from models import Person, ManualPrimaryKeyTest
+from .models import Person, ManualPrimaryKeyTest
class GetOrCreateTests(TestCase):
View
1  tests/modeltests/invalid_models/invalid_models/models.py
@@ -7,6 +7,7 @@
from django.db import connection, models
+
class FieldErrors(models.Model):
charfield = models.CharField()
charfield2 = models.CharField(max_length=-1)
View
4 tests/modeltests/invalid_models/tests.py
@@ -1,9 +1,9 @@
import copy
+import sys
+from cStringIO import StringIO
from django.core.management.validation import get_validation_errors
from django.db.models.loading import cache, load_app
-from cStringIO import StringIO
-import sys
from django.utils import unittest
View
1  tests/modeltests/lookup/models.py
@@ -6,6 +6,7 @@
from django.db import models
+
class Author(models.Model):
name = models.CharField(max_length=100)
class Meta:
View
8 tests/modeltests/lookup/tests.py
@@ -1,8 +1,12 @@
+from __future__ import absolute_import
+
from datetime import datetime
from operator import attrgetter
+
from django.core.exceptions import FieldError
from django.test import TestCase, skipUnlessDBFeature
-from models import Author, Article, Tag
+
+from .models import Author, Article, Tag
class LookupTests(TestCase):
@@ -243,7 +247,7 @@ def test_values(self):
self.assertQuerysetEqual(Article.objects.filter(id=self.a5.id).values(),
[{
'id': self.a5.id,
- 'author_id': self.au2.id,
+ 'author_id': self.au2.id,
'headline': 'Article 5',
'pub_date': datetime(2005, 8, 1, 9, 0)
}], transform=identity)
View
5 tests/modeltests/m2m_and_m2o/models.py
@@ -6,6 +6,7 @@
from django.db import models
+
class User(models.Model):
username = models.CharField(max_length=20)
@@ -20,6 +21,6 @@ def __unicode__(self):
class Meta:
ordering = ('num',)
-class UnicodeReferenceModel(models.Model):
- others = models.ManyToManyField(u"UnicodeReferenceModel")
+class UnicodeReferenceModel(models.Model):
+ others = models.ManyToManyField(u"UnicodeReferenceModel")
View
16 tests/modeltests/m2m_and_m2o/tests.py
@@ -1,7 +1,9 @@
+from __future__ import absolute_import
+
from django.db.models import Q
from django.test import TestCase
-from models import Issue, User, UnicodeReferenceModel
+from .models import Issue, User, UnicodeReferenceModel
class RelatedObjectTests(TestCase):
@@ -74,15 +76,15 @@ def test_m2m_and_m2o(self):
lambda i: i.num
)
-class RelatedObjectTests(TestCase):
- def test_m2m_with_unicode_reference(self):
+class RelatedObjectTests(TestCase):
+ def test_m2m_with_unicode_reference(self):
"""
Regression test for #6045: references to other models can be unicode
strings, providing they are directly convertible to ASCII.
"""
- m1=UnicodeReferenceModel.objects.create()
- m2=UnicodeReferenceModel.objects.create()
- m2.others.add(m1) # used to cause an error (see ticket #6045)
- m2.save()
+ m1=UnicodeReferenceModel.objects.create()
+ m2=UnicodeReferenceModel.objects.create()
+ m2.others.add(m1) # used to cause an error (see ticket #6045)
+ m2.save()
list(m2.others.all()) # Force retrieval.
View
1  tests/modeltests/m2m_intermediary/models.py
@@ -12,6 +12,7 @@
from django.db import models
+
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
View
4 tests/modeltests/m2m_intermediary/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from datetime import datetime
from django.test import TestCase
-from models import Reporter, Article, Writer
+from .models import Reporter, Article, Writer
class M2MIntermediaryTests(TestCase):
View
1  tests/modeltests/m2m_multiple/models.py
@@ -9,6 +9,7 @@
from django.db import models
+
class Category(models.Model):
name = models.CharField(max_length=20)
class Meta:
View
4 tests/modeltests/m2m_multiple/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from datetime import datetime
from django.test import TestCase
-from models import Article, Category
+from .models import Article, Category
class M2MMultipleTests(TestCase):
View
12 tests/modeltests/m2m_recursive/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from operator import attrgetter
from django.test import TestCase
-from models import Person
+from .models import Person
class RecursiveM2MTests(TestCase):
@@ -11,14 +13,14 @@ def test_recursive_m2m(self):
Person.objects.create(name=name)
for name in ["Anne", "Bill", "Chuck", "David"]
]
-
+
# Add some friends in the direction of field definition
# Anne is friends with Bill and Chuck
a.friends.add(b, c)
# David is friends with Anne and Chuck - add in reverse direction
d.friends.add(a,c)
-
+
# Who is friends with Anne?
self.assertQuerysetEqual(
a.friends.all(), [
@@ -54,7 +56,7 @@ def test_recursive_m2m(self):
# Bill is already friends with Anne - add Anne again, but in the
# reverse direction
b.friends.add(a)
-
+
# Who is friends with Anne?
self.assertQuerysetEqual(
a.friends.all(), [
@@ -115,7 +117,7 @@ def test_recursive_m2m(self):
b.idols.add(a)
# David is idolized by Anne and Chuck - add in reverse direction
d.stalkers.add(a, c)
-
+
# Who are Anne's idols?
self.assertQuerysetEqual(
a.idols.all(), [
View
4 tests/modeltests/m2m_signals/tests.py
@@ -2,10 +2,12 @@
Testing signals emitted on changing m2m relations.
"""
+from .models import Person
+
from django.db import models
from django.test import TestCase
-from models import Part, Car, SportsCar, Person
+from .models import Part, Car, SportsCar, Person
class ManyToManySignalsTest(TestCase):
View
4 tests/modeltests/m2m_through/models.py
@@ -1,6 +1,8 @@
-from django.db import models
from datetime import datetime
+from django.db import models
+
+
# M2M described on one of the models
class Person(models.Model):
name = models.CharField(max_length=128)
View
4 tests/modeltests/m2m_through/tests.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
from datetime import datetime
from operator import attrgetter
from django.test import TestCase
-from models import (Person, Group, Membership, CustomMembership,
+from .models import (Person, Group, Membership, CustomMembership,
PersonSelfRefM2M, Friendship)
View
1  tests/modeltests/m2o_recursive/models.py
@@ -12,6 +12,7 @@
from django.db import models
+
class Category(models.Model):
name = models.CharField(max_length=20)
parent = models.ForeignKey('self', blank=True, null=True, related_name='child_set')
View
6 tests/modeltests/m2o_recursive/tests.py
@@ -1,5 +1,9 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from models import Category, Person
+
+from .models import Category, Person
+
class ManyToOneRecursiveTests(TestCase):
View
1  tests/modeltests/many_to_many/models.py
@@ -9,6 +9,7 @@
from django.db import models
+
class Publication(models.Model):
title = models.CharField(max_length=30)
View
6 tests/modeltests/many_to_many/tests.py
@@ -1,5 +1,9 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from models import Article, Publication
+
+from .models import Article, Publication
+
class ManyToManyTests(TestCase):
View
1  tests/modeltests/many_to_one/models.py
@@ -6,6 +6,7 @@
from django.db import models
+
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
View
6 tests/modeltests/many_to_one/tests.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
from copy import deepcopy
from datetime import datetime
-from django.test import TestCase
from django.core.exceptions import MultipleObjectsReturned
+from django.test import TestCase
-from models import Article, Reporter
+from .models import Article, Reporter
class ManyToOneTests(TestCase):
View
1  tests/modeltests/many_to_one_null/models.py
@@ -7,6 +7,7 @@
from django.db import models
+
class Reporter(models.Model):
name = models.CharField(max_length=30)
View
5 tests/modeltests/many_to_one_null/tests.py
@@ -1,7 +1,8 @@
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
from django.test import TestCase
-from models import Reporter, Article
+
+from .models import Reporter, Article
class ManyToOneNullTests(TestCase):
View
3  tests/modeltests/model_forms/models.py
@@ -9,8 +9,9 @@
import tempfile
-from django.db import models
from django.core.files.storage import FileSystemStorage
+from django.db import models
+
temp_storage_dir = tempfile.mkdtemp()
temp_storage = FileSystemStorage(temp_storage_dir)
View
17 tests/modeltests/model_forms/tests.py
@@ -1,26 +1,25 @@
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
import datetime
import os
from decimal import Decimal
from django import forms
-from django.test import TestCase
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.validators import ValidationError
from django.db import connection
from django.forms.models import model_to_dict
from django.utils.unittest import skipUnless
+from django.test import TestCase
-from modeltests.model_forms.models import (Article, ArticleStatus,
- BetterWriter, BigInt, Book, Category, CommaSeparatedInteger,
- CustomFieldForExclusionModel, DerivedBook, DerivedPost, ExplicitPK,
- FlexibleDatePost, ImprovedArticle, ImprovedArticleWithParentLink,
- Inventory, PhoneNumber, Post, Price, Product, TextFile, Writer,
- WriterProfile, test_images)
+from .models import (Article, ArticleStatus, BetterWriter, BigInt, Book,
+ Category, CommaSeparatedInteger, CustomFieldForExclusionModel, DerivedBook,
+ DerivedPost, ExplicitPK, FlexibleDatePost, ImprovedArticle,
+ ImprovedArticleWithParentLink, Inventory, PhoneNumber, Post, Price,
+ Product, TextFile, Writer, WriterProfile, test_images)
if test_images:
- from modeltests.model_forms.models import ImageFile, OptionalImageFile
+ from .models import ImageFile, OptionalImageFile
class ImageFileForm(forms.ModelForm):
class Meta:
model = ImageFile
View
2  tests/modeltests/model_formsets/models.py
@@ -1,6 +1,8 @@
import datetime
+
from django.db import models
+
class Author(models.Model):
name = models.CharField(max_length=100)
View
6 tests/modeltests/model_formsets/tests.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
import datetime
import re
from datetime import date
@@ -9,13 +11,13 @@
modelformset_factory)
from django.test import TestCase, skipUnlessDBFeature
-from modeltests.model_formsets.models import (
- Author, BetterAuthor, Book, BookWithCustomPK,
+from .models import (Author, BetterAuthor, Book, BookWithCustomPK,
BookWithOptionalAltEditor, AlternateBook, AuthorMeeting, CustomPrimaryKey,
Place, Owner, Location, OwnerProfile, Restaurant, Product, Price,
MexicanRestaurant, ClassyMexicanRestaurant, Repository, Revision,
Person, Membership, Team, Player, Poet, Poem, Post)
+
class DeletionTests(TestCase):
def test_deletion(self):
PoetFormSet = modelformset_factory(Poet, can_delete=True)
View
4 tests/modeltests/model_inheritance/tests.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
from operator import attrgetter
from django.core.exceptions import FieldError
from django.test import TestCase
-from models import (Chef, CommonInfo, ItalianRestaurant, ParkingLot, Place,
+from .models import (Chef, CommonInfo, ItalianRestaurant, ParkingLot, Place,
Post, Restaurant, Student, StudentWorker, Supplier, Worker, MixinModel)
View
5 tests/modeltests/model_inheritance_same_model_name/models.py
@@ -6,8 +6,11 @@
this feature by redefining the Copy model from model_inheritance/models.py
"""
+from __future__ import absolute_import
+
from django.db import models
-from modeltests.model_inheritance.models import NamedURL
+
+from ..model_inheritance.models import NamedURL
#
# Abstract base classes with related models
View
6 tests/modeltests/model_inheritance_same_model_name/tests.py
@@ -1,5 +1,9 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from modeltests.model_inheritance.models import Title
+
+from ..model_inheritance.models import Title
+
class InheritanceSameModelNameTests(TestCase):
View
6 tests/modeltests/model_package/models/__init__.py
@@ -1,3 +1,5 @@
# Import all the models from subpackages
-from article import Article
-from publication import Publication
+from __future__ import absolute_import
+
+from .article import Article
+from .publication import Publication
View
3  tests/modeltests/model_package/models/article.py
@@ -1,5 +1,6 @@
-from django.db import models
from django.contrib.sites.models import Site
+from django.db import models
+
class Article(models.Model):
sites = models.ManyToManyField(Site)
View
1  tests/modeltests/model_package/models/publication.py
@@ -1,5 +1,6 @@
from django.db import models
+
class Publication(models.Model):
title = models.CharField(max_length=30)
View
6 tests/modeltests/model_package/tests.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
from django.contrib.sites.models import Site
from django.db import models
from django.test import TestCase
-from models.publication import Publication
-from models.article import Article
+from .models.publication import Publication
+from .models.article import Article
class Advertisment(models.Model):
View
6 tests/modeltests/mutually_referential/tests.py
@@ -1,5 +1,9 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from models import Parent
+
+from .models import Parent
+
class MutuallyReferentialTests(TestCase):
View
1  tests/modeltests/one_to_one/models.py
@@ -8,6 +8,7 @@
from django.db import models
+
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
View
8 tests/modeltests/one_to_one/tests.py
@@ -1,6 +1,10 @@
-from django.test import TestCase
+from __future__ import absolute_import
+
from django.db import transaction, IntegrityError
-from models import Place, Restaurant, Waiter, ManualPrimaryKey, RelatedModel, MultiModel
+from django.test import TestCase
+
+from .models import (Place, Restaurant, Waiter, ManualPrimaryKey, RelatedModel,
+ MultiModel)
class OneToOneTests(TestCase):
View
1  tests/modeltests/or_lookups/models.py
@@ -11,6 +11,7 @@
from django.db import models
+
class Article(models.Model):
headline = models.CharField(max_length=50)
pub_date = models.DateTimeField()
View
4 tests/modeltests/or_lookups/tests.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
from datetime import datetime
from operator import attrgetter
from django.db.models import Q
from django.test import TestCase
-from models import Article
+from .models import Article
class OrLookupsTests(TestCase):
View
18 tests/modeltests/order_with_respect_to/tests.py
@@ -1,22 +1,24 @@
+from __future__ import absolute_import
+
from operator import attrgetter
from django.test import TestCase
-from models import Post, Question, Answer
+from .models import Post, Question, Answer
class OrderWithRespectToTests(TestCase):
def test_basic(self):
q1 = Question.objects.create(text="Which Beatle starts with the letter 'R'?")
q2 = Question.objects.create(text="What is your name?")
-
+
Answer.objects.create(text="John", question=q1)
Answer.objects.create(text="Jonno", question=q2)
Answer.objects.create(text="Paul", question=q1)
Answer.objects.create(text="Paulo", question=q2)
Answer.objects.create(text="George", question=q1)
Answer.objects.create(text="Ringo", question=q1)
-
+
# The answers will always be ordered in the order they were inserted.
self.assertQuerysetEqual(
q1.answer_set.all(), [
@@ -24,7 +26,7 @@ def test_basic(self):
],
attrgetter("text"),
)
-
+
# We can retrieve the answers related to a particular object, in the
# order they were created, once we have a particular object.
a1 = Answer.objects.filter(question=q1)[0]
@@ -34,20 +36,20 @@ def test_basic(self):
a4 = list(Answer.objects.filter(question=q1))[-1]
self.assertEqual(a4.text, "Ringo")
self.assertEqual(a4.get_previous_in_order().text, "George")
-
+
# Determining (and setting) the ordering for a particular item is also
# possible.
id_list = [o.pk for o in q1.answer_set.all()]
self.assertEqual(a2.question.get_answer_order(), id_list)
-
+
a5 = Answer.objects.create(text="Number five", question=q1)
-
+
# It doesn't matter which answer we use to check the order, it will
# always be the same.
self.assertEqual(
a2.question.get_answer_order(), a5.question.get_answer_order()
)
-
+
# The ordering can be altered:
id_list = [o.pk for o in q1.answer_set.all()]
x = id_list.pop()
View
4 tests/modeltests/ordering/tests.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
from datetime import datetime
from operator import attrgetter
from django.test import TestCase
-from models import Article
+from .models import Article
class OrderingTests(TestCase):
View
30 tests/modeltests/pagination/tests.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
from datetime import datetime
from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.test import TestCase
-from models import Article
+from .models import Article
class CountContainer(object):
@@ -20,13 +22,13 @@ def setUp(self):
for x in range(1, 10):
a = Article(headline='Article %s' % x, pub_date=datetime(2005, 7, 29))
a.save()
-
+
def test_paginator(self):
paginator = Paginator(Article.objects.all(), 5)
self.assertEqual(9, paginator.count)
self.assertEqual(2, paginator.num_pages)
self.assertEqual([1, 2], paginator.page_range)
-
+
def test_first_page(self):
paginator = Paginator(Article.objects.all(), 5)
p = paginator.page(1)
@@ -46,7 +48,7 @@ def test_first_page(self):
self.assertEqual(0, p.previous_page_number())
self.assertEqual(1, p.start_index())
self.assertEqual(5, p.end_index())
-
+
def test_last_page(self):
paginator = Paginator(Article.objects.all(), 5)
p = paginator.page(2)
@@ -65,41 +67,41 @@ def test_last_page(self):
self.assertEqual(1, p.previous_page_number())
self.assertEqual(6, p.start_index())
self.assertEqual(9, p.end_index())
-
+
def test_empty_page(self):
paginator = Paginator(Article.objects.all(), 5)
self.assertRaises(EmptyPage, paginator.page, 0)
self.assertRaises(EmptyPage, paginator.page, 3)
-
+
# Empty paginators with allow_empty_first_page=True.
paginator = Paginator(Article.objects.filter(id=0), 5, allow_empty_first_page=True)
self.assertEqual(0, paginator.count)
self.assertEqual(1, paginator.num_pages)
self.assertEqual([1], paginator.page_range)
-
+
# Empty paginators with allow_empty_first_page=False.
paginator = Paginator(Article.objects.filter(id=0), 5, allow_empty_first_page=False)
self.assertEqual(0, paginator.count)
self.assertEqual(0, paginator.num_pages)
self.assertEqual([], paginator.page_range)
-
+
def test_invalid_page(self):
paginator = Paginator(Article.objects.all(), 5)
self.assertRaises(InvalidPage, paginator.page, 7)
-
+
def test_orphans(self):
# Add a few more records to test out the orphans feature.
for x in range(10, 13):
Article(headline="Article %s" % x, pub_date=datetime(2006, 10, 6)).save()
-
+
# With orphans set to 3 and 10 items per page, we should get all 12 items on a single page.
paginator = Paginator(Article.objects.all(), 10, orphans=3)
self.assertEqual(1, paginator.num_pages)
-
+
# With orphans only set to 1, we should get two pages.
paginator = Paginator(Article.objects.all(), 10, orphans=1)
self.assertEqual(2, paginator.num_pages)
-
+
def test_paginate_list(self):
# Paginators work with regular lists/tuples, too -- not just with QuerySets.
paginator = Paginator([1, 2, 3, 4, 5, 6, 7, 8, 9], 5)
@@ -116,14 +118,14 @@ def test_paginate_list(self):
self.assertEqual(0, p.previous_page_number())
self.assertEqual(1, p.start_index())
self.assertEqual(5, p.end_index())
-
+
def test_paginate_misc_classes(self):
# Paginator can be passed other objects with a count() method.
paginator = Paginator(CountContainer(), 10)
self.assertEqual(42, paginator.count)
self.assertEqual(5, paginator.num_pages)
self.assertEqual([1, 2, 3, 4, 5], paginator.page_range)
-
+
# Paginator can be passed other objects that implement __len__.
paginator = Paginator(LenContainer(), 10)
self.assertEqual(42, paginator.count)
View
2  tests/modeltests/prefetch_related/models.py
@@ -1,5 +1,5 @@
-from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
+from django.contrib.contenttypes.models import ContentType
from django.db import models
## Basic tests
View
10 tests/modeltests/prefetch_related/tests.py
@@ -1,13 +1,11 @@
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
-from django.utils import unittest
-from models import (Author, Book, Reader, Qualification, Teacher, Department,
- TaggedItem, Bookmark, AuthorAddress, FavoriteAuthors,
- AuthorWithAge, BookWithYear, Person, House, Room,
- Employee)
+from .models import (Author, Book, Reader, Qualification, Teacher, Department,
+ TaggedItem, Bookmark, AuthorAddress, FavoriteAuthors, AuthorWithAge,
+ BookWithYear, Person, House, Room, Employee)
class PrefetchRelatedTests(TestCase):
View
1  tests/modeltests/properties/models.py
@@ -6,6 +6,7 @@
from django.db import models
+
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
View
6 tests/modeltests/properties/tests.py
@@ -1,5 +1,9 @@
+from __future__ import with_statement, absolute_import
+
from django.test import TestCase
-from models import Person
+
+from .models import Person
+
class PropertyTests(TestCase):
View
4 tests/modeltests/proxy_model_inheritance/app1/models.py
@@ -1,5 +1,9 @@
+from __future__ import absolute_import
+
+# TODO: why can't I make this ..app2
from app2.models import NiceModel
+
class ProxyModel(NiceModel):
class Meta:
proxy = True
View
1  tests/modeltests/proxy_model_inheritance/app2/models.py
@@ -1,4 +1,5 @@
from django.db import models
+
class NiceModel(models.Model):
pass
View
8 tests/modeltests/proxy_model_inheritance/tests.py
@@ -6,6 +6,8 @@
apps and calls syncdb, then verifies that the table has been created.
"""
+from __future__ import absolute_import
+
import os
import sys
@@ -15,6 +17,7 @@
from django.test import TransactionTestCase
from django.test.utils import override_settings
+
# @override_settings(INSTALLED_APPS=('app1', 'app2'))
class ProxyModelInheritanceTests(TransactionTestCase):
@@ -28,9 +31,8 @@ def tearDown(self):
def test_table_exists(self):
call_command('syncdb', verbosity=0)
- global ProxyModel, NiceModel
- from app1.models import ProxyModel
- from app2.models import NiceModel
+ from .app1.models import ProxyModel
+ from .app2.models import NiceModel
self.assertEqual(NiceModel.objects.all().count(), 0)
self.assertEqual(ProxyModel.objects.all().count(), 0)
View
19 tests/modeltests/proxy_models/tests.py
@@ -1,16 +1,17 @@
-from django.test import TestCase
-from django.db import models, DEFAULT_DB_ALIAS
-from django.db.models import signals
+from __future__ import absolute_import
+
+from django.contrib.contenttypes.models import ContentType
from django.core import management
from django.core.exceptions import FieldError
+from django.db import models, DEFAULT_DB_ALIAS
+from django.db.models import signals
+from django.test import TestCase
-from django.contrib.contenttypes.models import ContentType
-from models import MyPerson, Person, StatusPerson, LowerStatusPerson
-from models import MyPersonProxy, Abstract, OtherPerson, User, UserProxy
-from models import UserProxyProxy, Country, State, StateProxy, TrackerUser
-from models import BaseUser, Bug, ProxyTrackerUser, Improvement, ProxyProxyBug
-from models import ProxyBug, ProxyImprovement
+from .models import (MyPerson, Person, StatusPerson, LowerStatusPerson,
+ MyPersonProxy, Abstract, OtherPerson, User, UserProxy, UserProxyProxy,
+ Country, State, StateProxy, TrackerUser, BaseUser, Bug, ProxyTrackerUser,
+ Improvement, ProxyProxyBug, ProxyBug, ProxyImprovement)
class ProxyModelTests(TestCase):
def test_same_manager_queries(self):
View
1  tests/modeltests/raw_query/models.py
@@ -1,5 +1,6 @@
from django.db import models
+
class Author(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
View
4 tests/modeltests/raw_query/tests.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
from datetime import date
from django.db.models.sql.query import InvalidQuery
from django.test import TestCase
-from models import Author, Book, Coffee, Reviewer, FriendlyAuthor
+from .models import Author, Book, Coffee, Reviewer, FriendlyAuthor
class RawQueryTests(TestCase):
View
1  tests/modeltests/reserved_names/models.py
@@ -9,6 +9,7 @@
from django.db import models
+
class Thing(models.Model):
when = models.CharField(max_length=1, primary_key=True)
join = models.CharField(max_length=1)
View
5 tests/modeltests/reserved_names/tests.py
@@ -1,8 +1,11 @@
+from __future__ import absolute_import
+
import datetime
from django.test import TestCase
-from models import Thing
+from .models import Thing
+
class ReservedNameTests(TestCase):
def generate(self):
View
1  tests/modeltests/reverse_lookup/models.py
@@ -6,6 +6,7 @@
from django.db import models
+
class User(models.Model):
name = models.CharField(max_length=200)
View
7 tests/modeltests/reverse_lookup/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 User, Poll, Choice
-from models import User, Poll, Choice
class ReverseLookupTests(TestCase):
View
4 tests/modeltests/save_delete_hooks/tests.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from models import Person
+from .models import Person
class SaveDeleteHookTests(TestCase):
View
1  tests/modeltests/select_for_update/models.py
@@ -1,4 +1,5 @@
from django.db import models
+
class Person(models.Model):
name = models.CharField(max_length=30)
View
7 tests/modeltests/select_for_update/tests.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
import sys
import time
-import unittest
+
from django.conf import settings
from django.db import transaction, connection
from django.db.utils import ConnectionHandler, DEFAULT_DB_ALIAS, DatabaseError
@@ -8,7 +10,7 @@
skipUnlessDBFeature)
from django.utils import unittest
-from models import Person
+from .models import Person
# Some tests require threading, which might not be available. So create a
# skip-test decorator for those test functions.
@@ -18,6 +20,7 @@
threading = None
requires_threading = unittest.skipUnless(threading, 'requires threading')
+
class SelectForUpdateTests(TransactionTestCase):
def setUp(self):
View
4 tests/modeltests/select_related/tests.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
from django.test import TestCase
-from models import Domain, Kingdom, Phylum, Klass, Order, Family, Genus, Species
+from .models import Domain, Kingdom, Phylum, Klass, Order, Family, Genus, Species
class SelectRelatedTests(TestCase):
View
1  tests/modeltests/serializers/models.py
@@ -7,6 +7,7 @@
"""
from decimal import Decimal
+
from django.db import models
View
9 tests/modeltests/serializers/tests.py
@@ -1,11 +1,11 @@
# This is necessary in Python 2.5 to enable the with statement, in 2.6
# and up it is no longer necessary.
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
# -*- coding: utf-8 -*-
from datetime import datetime
-from StringIO import StringIO
from xml.dom import minidom
+from StringIO import StringIO
from django.conf import settings
from django.core import serializers
@@ -13,8 +13,9 @@
from django.test import TestCase, TransactionTestCase, Approximate
from django.utils import simplejson, unittest
-from models import (Category, Author, Article, AuthorProfile,
- Actor, Movie, Score, Player, Team)
+from .models import (Category, Author, Article, AuthorProfile, Actor, Movie,
+ Score, Player, Team)
+
class SerializerRegistrationTests(unittest.TestCase):
def setUp(self):
View
4 tests/modeltests/signals/tests.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from django.db.models import signals
from django.dispatch import receiver
from django.test import TestCase
-from models import Person, Car
+from .models import Person, Car
# #8285: signals can be any callable
View
1  tests/modeltests/str/models.py
@@ -16,6 +16,7 @@
from django.db import models
+
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateTimeField()
View
5 tests/modeltests/str/tests.py
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
import datetime
from django.test import TestCase
-from models import Article, InternationalArticle
+from .models import Article, InternationalArticle
+
class SimpleTests(TestCase):
def test_basic(self):
View
4 tests/modeltests/test_client/models.py
@@ -20,11 +20,13 @@
rather than the HTML rendered to the end-user.
"""
+from __future__ import absolute_import
+
from django.conf import settings
from django.core import mail
from django.test import Client, TestCase, RequestFactory
-from views import get_view
+from .views import get_view
class ClientTest(TestCase):
View
7 tests/modeltests/test_client/tests.py
@@ -2,19 +2,20 @@
from django.utils import unittest
+
def suite():
"""
Define a suite that deliberately ignores a test defined in
this module.
"""
-
+
testSuite = unittest.TestSuite()
testSuite.addTest(SampleTests('testGoodStuff'))
return testSuite
-
+
class SampleTests(unittest.TestCase):
def testGoodStuff(self):
pass
-
+
def testBadStuff(self):
self.fail("This test shouldn't run")
View
6 tests/modeltests/test_client/urls.py
@@ -1,6 +1,10 @@
+from __future__ import absolute_import
+
from django.conf.urls import patterns
from django.views.generic import RedirectView
-import views
+
+from . import views
+
urlpatterns = patterns('',
(r'^get_view/$', views.get_view),
View
9 tests/modeltests/test_client/views.py
@@ -1,14 +1,15 @@
from xml.dom.minidom import parseString
-from django.core import mail
-from django.template import Context, Template
-from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
from django.contrib.auth.decorators import login_required, permission_required
-from django.forms.forms import Form
+from django.core import mail
from django.forms import fields
+from django.forms.forms import Form
+from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
from django.shortcuts import render_to_response
+from django.template import Context, Template
from django.utils.decorators import method_decorator
+
def get_view(request):
"A simple view that expects a GET request, and returns a rendered template"
t = Template('This is a test. {{ var }} is the value.', name='GET Template')
View
1  tests/modeltests/transactions/models.py
@@ -9,6 +9,7 @@
from django.db import models
+
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
View
4 tests/modeltests/transactions/tests.py
@@ -1,9 +1,9 @@
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
from django.db import connection, transaction, IntegrityError
from django.test import TransactionTestCase, skipUnlessDBFeature
-from models import Reporter
+from .models import Reporter
class TransactionTests(TransactionTestCase):
View
8 tests/modeltests/unmanaged_models/tests.py
@@ -1,6 +1,10 @@
-from django.test import TestCase
+from __future__ import absolute_import
+
from django.db import connection
-from models import A01, A02, B01, B02, C01, C02, Unmanaged2, Managed1
+from django.test import TestCase
+
+from .models import A01, A02, B01, B02, C01, C02, Unmanaged2, Managed1
+
class SimpleTests(TestCase):