Permalink
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...
1 parent 99512d3 commit d5a45d79fe03cad93ab5761860e9bb6fc1db4c86 @alex alex committed Oct 13, 2011
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
@@ -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):
@@ -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()
@@ -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):
@@ -11,6 +11,7 @@
from django.db import models
+
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
@@ -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 = ''
@@ -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')
@@ -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):
@@ -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):
@@ -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()
@@ -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):
@@ -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')
@@ -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):
@@ -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):
@@ -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)
@@ -1,5 +1,6 @@
from django.test import TestCase
+
class NoModelTests(TestCase):
""" A placeholder test case. See modeltests.empty.tests for more info. """
pass
@@ -1,12 +1,12 @@
-from __future__ import with_statement
+from __future__ import with_statement, absolute_import
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db.models.loading import get_app
from django.test import TestCase
from django.test.utils import override_settings
-from models import Empty
+from .models import Empty
class EmptyModelTests(TestCase):
@@ -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)
@@ -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):
@@ -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)
@@ -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):
@@ -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
@@ -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):
@@ -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):
@@ -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):
@@ -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):
@@ -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):
@@ -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()
@@ -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):
@@ -4,6 +4,7 @@
"""
from django.db import models
+
class Counter(models.Model):
name = models.CharField(max_length = 10)
value = models.IntegerField()
@@ -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):
@@ -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)
@@ -10,6 +10,7 @@
from django.db import models
+
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
@@ -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):
@@ -12,6 +12,7 @@
from django.db import models
+
class Author(models.Model):
name = models.CharField(max_length=50)
@@ -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):
Oops, something went wrong.

0 comments on commit d5a45d7

Please sign in to comment.