Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into schema-alteration

  • Loading branch information...
commit b1e0ec06f0d538eb2ab16a7c1ecefd1d896e6382 2 parents 7a47ba6 + 6c66a41
@andrewgodwin andrewgodwin authored
Showing with 694 additions and 4,096 deletions.
  1. +1 −2  INSTALL
  2. +0 −19 django/bin/daily_cleanup.py
  3. +8 −14 django/conf/__init__.py
  4. +1 −1  django/conf/global_settings.py
  5. +1 −1  django/conf/urls/shortcut.py
  6. +1 −1  django/contrib/admin/options.py
  7. +1 −1  django/contrib/admin/tests.py
  8. +2 −1  django/contrib/admin/util.py
  9. +4 −4 django/contrib/admin/views/main.py
  10. +2 −1  django/contrib/admindocs/tests/test_fields.py
  11. +0 −6 django/contrib/auth/forms.py
  12. +0 −39 django/contrib/auth/models.py
  13. +3 −2 django/contrib/auth/tests/test_hashers.py
  14. +1 −38 django/contrib/auth/tests/test_models.py
  15. +2 −2 django/contrib/auth/tests/test_tokens.py
  16. +1 −21 django/contrib/auth/tests/test_views.py
  17. +2 −1  django/contrib/auth/tests/utils.py
  18. +0 −3  django/contrib/auth/urls.py
  19. +0 −9 django/contrib/auth/views.py
  20. +1 −1  django/contrib/comments/__init__.py
  21. +1 −1  django/contrib/comments/templatetags/comments.py
  22. +3 −3 django/contrib/contenttypes/generic.py
  23. +1 −1  django/contrib/formtools/tests/tests.py
  24. +0 −6 django/contrib/gis/forms/fields.py
  25. +3 −2 django/contrib/gis/gdal/tests/test_driver.py
  26. +2 −2 django/contrib/gis/gdal/tests/test_ds.py
  27. +4 −3 django/contrib/gis/gdal/tests/test_envelope.py
  28. +2 −2 django/contrib/gis/gdal/tests/test_geom.py
  29. +3 −2 django/contrib/gis/gdal/tests/test_srs.py
  30. +3 −2 django/contrib/gis/geoip/tests.py
  31. +2 −2 django/contrib/gis/geos/tests/test_geos.py
  32. +2 −2 django/contrib/gis/geos/tests/test_geos_mutation.py
  33. +1 −1  django/contrib/gis/geos/tests/test_io.py
  34. +3 −1 django/contrib/gis/geos/tests/test_mutable_list.py
  35. +2 −1  django/contrib/gis/tests/distapp/tests.py
  36. +1 −1  django/contrib/gis/tests/geo3d/tests.py
  37. +2 −1  django/contrib/gis/tests/geoadmin/tests.py
  38. +1 −1  django/contrib/gis/tests/geoapp/test_feeds.py
  39. +1 −1  django/contrib/gis/tests/geoapp/test_regress.py
  40. +1 −1  django/contrib/gis/tests/geoapp/test_sitemaps.py
  41. +3 −2 django/contrib/gis/tests/geoapp/tests.py
  42. +1 −1  django/contrib/gis/tests/geogapp/tests.py
  43. +1 −1  django/contrib/gis/tests/inspectapp/tests.py
  44. +3 −3 django/contrib/gis/tests/layermap/tests.py
  45. +2 −1  django/contrib/gis/tests/relatedapp/tests.py
  46. +4 −3 django/contrib/gis/tests/test_geoforms.py
  47. +2 −1  django/contrib/gis/tests/test_measure.py
  48. +2 −1  django/contrib/gis/tests/test_spatialrefsys.py
  49. +1 −1  django/contrib/humanize/tests.py
  50. +2 −1  django/contrib/messages/tests/base.py
  51. +2 −1  django/contrib/messages/tests/test_middleware.py
  52. +5 −2 django/contrib/sessions/middleware.py
  53. +1 −1  django/contrib/sessions/tests.py
  54. +2 −1  django/contrib/sitemaps/tests/test_flatpages.py
  55. +1 −1  django/contrib/sitemaps/tests/test_http.py
  56. +2 −15 django/contrib/sitemaps/views.py
  57. +1 −0  django/core/files/storage.py
  58. +0 −11 django/core/management/commands/cleanup.py
  59. +2 −2 django/db/__init__.py
  60. +23 −11 django/db/backends/__init__.py
  61. +1 −1  django/db/backends/creation.py
  62. +1 −1  django/db/backends/mysql/base.py
  63. +2 −8 django/db/backends/sqlite3/base.py
  64. +2 −0  django/db/models/fields/files.py
  65. +5 −8 django/db/models/fields/related.py
  66. +2 −2 django/db/models/manager.py
  67. +4 −4 django/db/models/options.py
  68. +0 −9 django/db/models/query.py
  69. +11 −15 django/db/transaction.py
  70. +2 −7 django/db/utils.py
  71. +1 −1  django/forms/forms.py
  72. +3 −3 django/forms/models.py
  73. +1 −1  django/forms/widgets.py
  74. +4 −4 django/http/__init__.py
  75. +3 −65 django/http/response.py
  76. +1 −1  django/middleware/cache.py
  77. +1 −1  django/middleware/common.py
  78. +1 −1  django/middleware/doc.py
  79. +1 −1  django/middleware/transaction.py
  80. +0 −8 django/shortcuts/__init__.py
  81. +2 −2 django/template/defaulttags.py
  82. +4 −6 django/template/response.py
  83. +1 −1  django/test/_doctest.py
  84. +2 −2 django/test/runner.py
  85. +3 −1 django/test/simple.py
  86. +9 −28 django/test/testcases.py
  87. +9 −28 django/test/utils.py
  88. +0 −26 django/utils/datastructures.py
  89. +5 −0 django/utils/dictconfig.py
  90. +0 −24 django/utils/encoding.py
  91. +1 −1  django/utils/image.py
  92. +0 −7 django/utils/itercompat.py
  93. +4 −17 django/utils/log.py
  94. +0 −31 django/utils/simplejson.py
  95. +11 −0 django/utils/unittest.py
  96. +0 −80 django/utils/unittest/__init__.py
  97. +0 −10 django/utils/unittest/__main__.py
  98. +0 −1,076 django/utils/unittest/case.py
  99. +0 −9 django/utils/unittest/collector.py
  100. +0 −64 django/utils/unittest/compatibility.py
  101. +0 −322 django/utils/unittest/loader.py
  102. +0 −241 django/utils/unittest/main.py
  103. +0 −183 django/utils/unittest/result.py
  104. +0 −206 django/utils/unittest/runner.py
  105. +0 −57 django/utils/unittest/signals.py
  106. +0 −287 django/utils/unittest/suite.py
  107. +0 −99 django/utils/unittest/util.py
  108. +1 −1  django/views/defaults.py
  109. +1 −1  django/views/generic/edit.py
  110. +4 −4 django/views/static.py
  111. +26 −27 docs/faq/install.txt
  112. +11 −1 docs/internals/deprecation.txt
  113. +5 −6 docs/intro/install.txt
  114. +0 −14 docs/ref/contrib/auth.txt
  115. +3 −3 docs/ref/contrib/contenttypes.txt
  116. +0 −12 docs/ref/django-admin.txt
  117. +0 −16 docs/ref/models/querysets.txt
  118. +5 −21 docs/ref/request-response.txt
  119. +5 −17 docs/ref/settings.txt
  120. +2 −4 docs/ref/template-response.txt
  121. +1 −26 docs/ref/utils.txt
  122. +5 −5 docs/releases/1.5-alpha-1.txt
  123. +6 −6 docs/releases/1.5-beta-1.txt
  124. +6 −6 docs/releases/1.5.txt
  125. +3 −3 docs/releases/1.6.txt
  126. +47 −0 docs/releases/1.7.txt
  127. +0 −34 docs/topics/auth/customizing.txt
  128. +12 −13 docs/topics/class-based-views/mixins.txt
  129. +2 −4 docs/topics/install.txt
  130. +1 −10 docs/topics/logging.txt
  131. +21 −229 docs/topics/testing/_images/django_unittest_classes_hierarchy.graffle
  132. BIN  docs/topics/testing/_images/django_unittest_classes_hierarchy.pdf
  133. +1 −1  docs/topics/testing/_images/django_unittest_classes_hierarchy.svg
  134. +1 −1  docs/topics/testing/advanced.txt
  135. +11 −26 docs/topics/testing/overview.txt
  136. +1 −1  setup.cfg
  137. +0 −1  setup.py
  138. +1 −1  tests/.coveragerc
  139. +3 −3 tests/admin_scripts/app_with_import/models.py
  140. +2 −3 tests/admin_scripts/tests.py
  141. +11 −8 tests/admin_views/tests.py
  142. +1 −1  tests/admin_widgets/tests.py
  143. +0 −1  tests/aggregation_regress/tests.py
  144. +2 −1  tests/app_loading/tests.py
  145. +15 −3 tests/backends/tests.py
  146. +1 −1  tests/bash_completion/tests.py
  147. +1 −1  tests/bug639/tests.py
  148. +2 −1  tests/bug8245/tests.py
  149. +1 −1  tests/builtin_server/tests.py
  150. +7 −4 tests/cache/tests.py
  151. +1 −1  tests/db_typecasts/tests.py
  152. +1 −1  tests/decorators/tests.py
  153. +2 −1  tests/defaultfilters/tests.py
  154. +1 −1  tests/deprecation/tests.py
  155. +1 −1  tests/dispatch/tests/test_dispatcher.py
  156. +2 −1  tests/dispatch/tests/test_saferef.py
  157. +9 −1 tests/file_storage/tests.py
  158. +1 −1  tests/file_uploads/tests.py
  159. +1 −1  tests/files/tests.py
  160. +27 −29 tests/fixtures/tests.py
  161. +3 −4 tests/fixtures_model_package/tests.py
  162. +0 −32 tests/fixtures_regress/tests.py
  163. +2 −1  tests/forms_tests/tests/test_validators.py
  164. +1 −1  tests/generic_views/test_base.py
  165. +1 −1  tests/generic_views/test_dates.py
  166. +4 −4 tests/generic_views/test_edit.py
  167. +7 −20 tests/httpwrappers/tests.py
  168. +2 −1  tests/indexes/tests.py
  169. +1 −1  tests/inspectdb/tests.py
  170. +2 −1  tests/introspection/tests.py
  171. +1 −2  tests/invalid_models/tests.py
  172. +1 −1  tests/logging_tests/tests.py
  173. +2 −2 tests/max_lengths/tests.py
  174. +6 −6 tests/middleware/tests.py
  175. +1 −1  tests/model_fields/test_imagefield.py
  176. +12 −1 tests/model_fields/tests.py
  177. +5 −3 tests/model_forms/tests.py
  178. +3 −3 tests/model_forms_regress/tests.py
  179. +1 −1  tests/model_formsets/tests.py
  180. +2 −2 tests/model_inheritance_regress/tests.py
  181. +1 −1  tests/model_regress/tests.py
  182. +2 −1  tests/modeladmin/tests.py
  183. +0 −21 tests/multiple_database/tests.py
  184. +1 −1  tests/pagination/tests.py
  185. +1 −1  tests/proxy_models/tests.py
  186. +1 −1  tests/queries/tests.py
  187. +3 −3 tests/requests/tests.py
  188. +2 −1  tests/resolve_url/tests.py
  189. +1 −1  tests/runtests.py
  190. +1 −1  tests/select_for_update/tests.py
  191. +13 −45 tests/select_related/tests.py
  192. +2 −1  tests/select_related_onetoone/tests.py
  193. +1 −1  tests/serializers/tests.py
  194. +2 −2 tests/serializers_regress/tests.py
  195. +2 −1  tests/settings_tests/tests.py
  196. +1 −1  tests/str/tests.py
  197. +4 −3 tests/template_tests/loaders.py
  198. +2 −1  tests/template_tests/test_callables.py
  199. +3 −1 tests/template_tests/test_context.py
  200. +2 −1  tests/template_tests/test_custom.py
  201. +2 −1  tests/template_tests/test_nodelist.py
  202. +2 −1  tests/template_tests/test_parser.py
  203. +2 −1  tests/template_tests/test_smartif.py
  204. +2 −1  tests/template_tests/test_unicode.py
  205. +2 −2 tests/template_tests/tests.py
  206. +2 −9 tests/test_discovery_sample/tests_sample.py
  207. +3 −32 tests/test_runner/test_discover_runner.py
  208. +5 −4 tests/test_runner/tests.py
  209. +5 −3 tests/test_suite_override/tests.py
  210. +5 −36 tests/test_utils/tests.py
  211. +1 −1  tests/timezones/tests.py
  212. +5 −5 tests/transactions/tests.py
  213. +8 −7 tests/transactions_regress/tests.py
  214. +3 −1 tests/urlpatterns_reverse/tests.py
  215. +1 −1  tests/utils_tests/test_archive.py
  216. +2 −1  tests/utils_tests/test_baseconv.py
  217. +2 −2 tests/utils_tests/test_crypto.py
  218. +0 −15 tests/utils_tests/test_datastructures.py
  219. +3 −1 tests/utils_tests/test_dateformat.py
  220. +1 −1  tests/utils_tests/test_dateparse.py
  221. +2 −1  tests/utils_tests/test_encoding.py
  222. +4 −1 tests/utils_tests/test_feedgenerator.py
  223. +2 −1  tests/utils_tests/test_functional.py
  224. +1 −1  tests/utils_tests/test_html.py
  225. +1 −1  tests/utils_tests/test_http.py
  226. +2 −1  tests/utils_tests/test_ipv6.py
  227. +2 −2 tests/utils_tests/test_module_loading.py
  228. +1 −1  tests/utils_tests/test_os_utils.py
  229. +2 −1  tests/utils_tests/test_regex_helper.py
  230. +1 −1  tests/utils_tests/test_simplelazyobject.py
  231. +2 −1  tests/utils_tests/test_termcolors.py
  232. +2 −1  tests/utils_tests/test_timezone.py
  233. +2 −1  tests/utils_tests/test_tzinfo.py
  234. +2 −1  tests/validation/test_error_messages.py
  235. +1 −1  tests/validation/test_unique.py
  236. +2 −2 tests/validators/tests.py
  237. +1 −1  tests/version/tests.py
  238. +1 −1  tests/view_tests/tests/test_debug.py
  239. +2 −1  tests/view_tests/tests/test_i18n.py
  240. +3 −1 tests/wsgi/tests.py
View
3  INSTALL
@@ -1,6 +1,6 @@
Thanks for downloading Django.
-To install it, make sure you have Python 2.6 or greater installed. Then run
+To install it, make sure you have Python 2.7 or greater installed. Then run
this command from the command prompt:
python setup.py install
@@ -12,7 +12,6 @@ site-packages directory, which is located wherever your Python installation
lives. Some places you might check are:
/usr/lib/python2.7/site-packages (Unix, Python 2.7)
- /usr/lib/python2.6/site-packages (Unix, Python 2.6)
C:\\PYTHON\site-packages (Windows)
For more detailed instructions, see docs/intro/install.txt.
View
19 django/bin/daily_cleanup.py
@@ -1,19 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Daily cleanup job.
-
-Can be run as a cronjob to clean out old data from the database (only expired
-sessions at the moment).
-"""
-
-import warnings
-
-from django.core import management
-
-if __name__ == "__main__":
- warnings.warn(
- "The `daily_cleanup` script has been deprecated "
- "in favor of `django-admin.py clearsessions`.",
- DeprecationWarning)
- management.call_command('clearsessions')
View
22 django/conf/__init__.py
@@ -59,14 +59,10 @@ def _configure_logging(self):
Setup logging from LOGGING_CONFIG and LOGGING settings.
"""
if not sys.warnoptions:
- try:
- # Route warnings through python logging
- logging.captureWarnings(True)
- # Allow DeprecationWarnings through the warnings filters
- warnings.simplefilter("default", DeprecationWarning)
- except AttributeError:
- # No captureWarnings on Python 2.6, DeprecationWarnings are on anyway
- pass
+ # Route warnings through python logging
+ logging.captureWarnings(True)
+ # Allow DeprecationWarnings through the warnings filters
+ warnings.simplefilter("default", DeprecationWarning)
if self.LOGGING_CONFIG:
from django.utils.log import DEFAULT_LOGGING
@@ -132,19 +128,17 @@ def __init__(self, settings_module):
% (self.SETTINGS_MODULE, e)
)
- # Settings that should be converted into tuples if they're mistakenly entered
- # as strings.
tuple_settings = ("INSTALLED_APPS", "TEMPLATE_DIRS")
for setting in dir(mod):
if setting == setting.upper():
setting_value = getattr(mod, setting)
+
if setting in tuple_settings and \
isinstance(setting_value, six.string_types):
- warnings.warn("The %s setting must be a tuple. Please fix your "
- "settings, as auto-correction is now deprecated." % setting,
- DeprecationWarning, stacklevel=2)
- setting_value = (setting_value,) # In case the user forgot the comma.
+ raise ImproperlyConfigured("The %s setting must be a tuple. "
+ "Please fix your settings." % setting)
+
setattr(self, setting, setting_value)
if not self.SECRET_KEY:
View
2  django/conf/global_settings.py
@@ -562,7 +562,7 @@
###########
# The callable to use to configure logging
-LOGGING_CONFIG = 'django.utils.log.dictConfig'
+LOGGING_CONFIG = 'logging.config.dictConfig'
# Custom logging configuration.
LOGGING = {}
View
2  django/conf/urls/shortcut.py
@@ -3,7 +3,7 @@
from django.conf.urls import patterns
warnings.warn("django.conf.urls.shortcut will be removed in Django 1.8.",
- PendingDeprecationWarning)
+ DeprecationWarning)
urlpatterns = patterns('django.views',
(r'^(?P<content_type_id>\d+)/(?P<object_id>.*)/$', 'defaults.shortcut'),
View
2  django/contrib/admin/options.py
@@ -76,7 +76,7 @@ class IncorrectLookupParameters(Exception):
class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase):
renamed_methods = (
- ('queryset', 'get_queryset', PendingDeprecationWarning),
+ ('queryset', 'get_queryset', DeprecationWarning),
)
View
2  django/contrib/admin/tests.py
@@ -1,8 +1,8 @@
import os
+from unittest import SkipTest
from django.test import LiveServerTestCase
from django.utils.module_loading import import_by_path
-from django.utils.unittest import SkipTest
from django.utils.translation import ugettext as _
View
3  django/contrib/admin/util.py
@@ -3,6 +3,7 @@
import datetime
import decimal
+from django.contrib.auth import get_permission_codename
from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.deletion import Collector
@@ -119,7 +120,7 @@ def format_callback(obj):
opts.model_name),
None, (quote(obj._get_pk_val()),))
p = '%s.%s' % (opts.app_label,
- opts.get_delete_permission())
+ get_permission_codename('delete', opts))
if not user.has_perm(p):
perms_needed.add(opts.verbose_name)
# Display a link to the admin page.
View
8 django/contrib/admin/views/main.py
@@ -52,7 +52,7 @@ def _is_changelist_popup(request):
warnings.warn(
"The `%s` GET parameter has been renamed to `%s`." %
(IS_LEGACY_POPUP_VAR, IS_POPUP_VAR),
- PendingDeprecationWarning, 2)
+ DeprecationWarning, 2)
return True
return False
@@ -60,7 +60,7 @@ def _is_changelist_popup(request):
class RenameChangeListMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', PendingDeprecationWarning),
+ ('get_query_set', 'get_queryset', DeprecationWarning),
)
@@ -115,14 +115,14 @@ def __init__(self, request, model, list_display, list_display_links,
def root_query_set(self):
warnings.warn("`ChangeList.root_query_set` is deprecated, "
"use `root_queryset` instead.",
- PendingDeprecationWarning, 2)
+ DeprecationWarning, 2)
return self.root_queryset
@property
def query_set(self):
warnings.warn("`ChangeList.query_set` is deprecated, "
"use `queryset` instead.",
- PendingDeprecationWarning, 2)
+ DeprecationWarning, 2)
return self.queryset
def get_filters_params(self, params=None):
View
3  django/contrib/admindocs/tests/test_fields.py
@@ -1,9 +1,10 @@
from __future__ import absolute_import, unicode_literals
+import unittest
+
from django.contrib.admindocs import views
from django.db import models
from django.db.models import fields
-from django.utils import unittest
from django.utils.translation import ugettext as _
View
6 django/contrib/auth/forms.py
@@ -1,7 +1,5 @@
from __future__ import unicode_literals
-import warnings
-
from django import forms
from django.forms.util import flatatt
from django.template import loader
@@ -200,10 +198,6 @@ def clean(self):
)
return self.cleaned_data
- def check_for_test_cookie(self):
- warnings.warn("check_for_test_cookie is deprecated; ensure your login "
- "view is CSRF-protected.", DeprecationWarning)
-
def get_user_id(self):
if self.user_cache:
return self.user_cache.id
View
39 django/contrib/auth/models.py
@@ -1,8 +1,6 @@
from __future__ import unicode_literals
import re
-import warnings
-from django.core.exceptions import ImproperlyConfigured
from django.core.mail import send_mail
from django.core import validators
from django.db import models
@@ -14,7 +12,6 @@
from django.utils import timezone
from django.contrib import auth
-# UNUSABLE_PASSWORD is still imported here for backwards compatibility
from django.contrib.auth.hashers import (
check_password, make_password, is_password_usable)
from django.contrib.auth.signals import user_logged_in
@@ -32,10 +29,6 @@ def update_last_login(sender, user, **kwargs):
user_logged_in.connect(update_last_login)
-class SiteProfileNotAvailable(Exception):
- pass
-
-
class PermissionManager(models.Manager):
def get_by_natural_key(self, codename, app_label, model):
return self.get(
@@ -413,38 +406,6 @@ def email_user(self, subject, message, from_email=None):
"""
send_mail(subject, message, from_email, [self.email])
- def get_profile(self):
- """
- Returns site-specific profile for this user. Raises
- SiteProfileNotAvailable if this site does not allow profiles.
- """
- warnings.warn("The use of AUTH_PROFILE_MODULE to define user profiles has been deprecated.",
- DeprecationWarning, stacklevel=2)
- if not hasattr(self, '_profile_cache'):
- from django.conf import settings
- if not getattr(settings, 'AUTH_PROFILE_MODULE', False):
- raise SiteProfileNotAvailable(
- 'You need to set AUTH_PROFILE_MODULE in your project '
- 'settings')
- try:
- app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')
- except ValueError:
- raise SiteProfileNotAvailable(
- 'app_label and model_name should be separated by a dot in '
- 'the AUTH_PROFILE_MODULE setting')
- try:
- model = models.get_model(app_label, model_name)
- if model is None:
- raise SiteProfileNotAvailable(
- 'Unable to load the profile model, check '
- 'AUTH_PROFILE_MODULE in your project settings')
- self._profile_cache = model._default_manager.using(
- self._state.db).get(user__id__exact=self.id)
- self._profile_cache.user = self
- except (ImportError, ImproperlyConfigured):
- raise SiteProfileNotAvailable
- return self._profile_cache
-
class User(AbstractUser):
"""
View
5 django/contrib/auth/tests/test_hashers.py
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+import unittest
+from unittest import skipUnless
+
from django.conf.global_settings import PASSWORD_HASHERS as default_hashers
from django.contrib.auth.hashers import (is_password_usable, BasePasswordHasher,
check_password, make_password, PBKDF2PasswordHasher, load_hashers, PBKDF2SHA1PasswordHasher,
get_hasher, identify_hasher, UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH)
from django.utils import six
-from django.utils import unittest
-from django.utils.unittest import skipUnless
try:
View
39 django/contrib/auth/tests/test_models.py
@@ -1,46 +1,9 @@
-import warnings
-
-from django.conf import settings
from django.contrib.auth import get_user_model
-from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable,
- UserManager)
+from django.contrib.auth.models import Group, User, UserManager
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.db.models.signals import post_save
from django.test import TestCase
from django.test.utils import override_settings
-from django.utils import six
-
-
-@skipIfCustomUser
-@override_settings(USE_TZ=False, AUTH_PROFILE_MODULE='')
-class ProfileTestCase(TestCase):
-
- def test_site_profile_not_available(self):
- user = User.objects.create(username='testclient')
-
- # calling get_profile without AUTH_PROFILE_MODULE set
- del settings.AUTH_PROFILE_MODULE
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
- with six.assertRaisesRegex(self, SiteProfileNotAvailable,
- "You need to set AUTH_PROFILE_MODULE in your project"):
- user.get_profile()
-
- # Bad syntax in AUTH_PROFILE_MODULE:
- settings.AUTH_PROFILE_MODULE = 'foobar'
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
- with six.assertRaisesRegex(self, SiteProfileNotAvailable,
- "app_label and model_name should be separated by a dot"):
- user.get_profile()
-
- # module that doesn't exist
- settings.AUTH_PROFILE_MODULE = 'foo.bar'
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
- with six.assertRaisesRegex(self, SiteProfileNotAvailable,
- "Unable to load the profile model"):
- user.get_profile()
@skipIfCustomUser
View
4 django/contrib/auth/tests/test_tokens.py
@@ -1,12 +1,12 @@
-import sys
from datetime import date, timedelta
+import sys
+import unittest
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.test import TestCase
-from django.utils import unittest
@skipIfCustomUser
View
22 django/contrib/auth/tests/test_views.py
@@ -13,7 +13,7 @@
from django.core.urlresolvers import reverse, NoReverseMatch
from django.http import QueryDict, HttpRequest
from django.utils.encoding import force_text
-from django.utils.http import int_to_base36, urlsafe_base64_decode, urlquote
+from django.utils.http import urlquote
from django.utils._os import upath
from django.test import TestCase
from django.test.utils import override_settings, patch_logger
@@ -193,16 +193,6 @@ def test_confirm_valid(self):
# redirect to a 'complete' page:
self.assertContains(response, "Please enter your new password")
- def test_confirm_valid_base36(self):
- # Remove in Django 1.7
- url, path = self._test_confirm_start()
- path_parts = path.strip("/").split("/")
- # construct an old style (base36) URL by converting the base64 ID
- path_parts[1] = int_to_base36(int(urlsafe_base64_decode(path_parts[1])))
- response = self.client.get("/%s/%s-%s/" % tuple(path_parts))
- # redirect to a 'complete' page:
- self.assertContains(response, "Please enter your new password")
-
def test_confirm_invalid(self):
url, path = self._test_confirm_start()
# Let's munge the token in the path, but keep the same length,
@@ -217,21 +207,11 @@ def test_confirm_invalid_user(self):
response = self.client.get('/reset/123456/1-1/')
self.assertContains(response, "The password reset link was invalid")
- def test_confirm_invalid_user_base36(self):
- # Remove in Django 1.7
- response = self.client.get('/reset/123456-1-1/')
- self.assertContains(response, "The password reset link was invalid")
-
def test_confirm_overflow_user(self):
# Ensure that we get a 200 response for a base36 user id that overflows int
response = self.client.get('/reset/zzzzzzzzzzzzz/1-1/')
self.assertContains(response, "The password reset link was invalid")
- def test_confirm_overflow_user_base36(self):
- # Remove in Django 1.7
- response = self.client.get('/reset/zzzzzzzzzzzzz-1-1/')
- self.assertContains(response, "The password reset link was invalid")
-
def test_confirm_invalid_post(self):
# Same as test_confirm_invalid, but trying
# to do a POST instead.
View
3  django/contrib/auth/tests/utils.py
@@ -1,5 +1,6 @@
+from unittest import skipIf
+
from django.conf import settings
-from django.utils.unittest import skipIf
def skipIfCustomUser(test_func):
View
3  django/contrib/auth/urls.py
@@ -12,9 +12,6 @@
url(r'^password_change/done/$', 'django.contrib.auth.views.password_change_done', name='password_change_done'),
url(r'^password_reset/$', 'django.contrib.auth.views.password_reset', name='password_reset'),
url(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
- # Support old style base36 password reset links; remove in Django 1.7
- url(r'^reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
- 'django.contrib.auth.views.password_reset_confirm_uidb36'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
'django.contrib.auth.views.password_reset_confirm',
name='password_reset_confirm'),
View
9 django/contrib/auth/views.py
@@ -228,15 +228,6 @@ def password_reset_confirm(request, uidb64=None, token=None,
return TemplateResponse(request, template_name, context,
current_app=current_app)
-def password_reset_confirm_uidb36(request, uidb36=None, **kwargs):
- # Support old password reset URLs that used base36 encoded user IDs.
- # Remove in Django 1.7
- try:
- uidb64 = force_text(urlsafe_base64_encode(force_bytes(base36_to_int(uidb36))))
- except ValueError:
- uidb64 = '1' # dummy invalid ID (incorrect padding for base64)
- return password_reset_confirm(request, uidb64=uidb64, **kwargs)
-
def password_reset_complete(request,
template_name='registration/password_reset_complete.html',
current_app=None, extra_context=None):
View
2  django/contrib/comments/__init__.py
@@ -6,7 +6,7 @@
from django.contrib.comments.forms import CommentForm
from django.utils.importlib import import_module
-warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", PendingDeprecationWarning)
+warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", DeprecationWarning)
DEFAULT_COMMENTS_APP = 'django.contrib.comments'
View
2  django/contrib/comments/templatetags/comments.py
@@ -12,7 +12,7 @@
class RenameBaseCommentNodeMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', PendingDeprecationWarning),
+ ('get_query_set', 'get_queryset', DeprecationWarning),
)
View
6 django/contrib/contenttypes/generic.py
@@ -25,7 +25,7 @@
class RenameGenericForeignKeyMethods(RenameMethodsBase):
renamed_methods = (
- ('get_prefetch_query_set', 'get_prefetch_queryset', PendingDeprecationWarning),
+ ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
)
@@ -434,8 +434,8 @@ def generic_inlineformset_factory(model, form=ModelForm,
"""
Returns a ``GenericInlineFormSet`` for the given kwargs.
- You must provide ``ct_field`` and ``object_id`` if they different from the
- defaults ``content_type`` and ``object_id`` respectively.
+ You must provide ``ct_field`` and ``fk_field`` if they are different from
+ the defaults ``content_type`` and ``object_id`` respectively.
"""
opts = model._meta
# if there is no field called `ct_field` let the exception propagate
View
2  django/contrib/formtools/tests/tests.py
@@ -3,6 +3,7 @@
import datetime
import os
+import unittest
import warnings
from django import http
@@ -10,7 +11,6 @@
from django.test import TestCase
from django.test.utils import override_settings
from django.utils._os import upath
-from django.utils import unittest
from django.contrib.formtools.tests.forms import *
View
6 django/contrib/gis/forms/fields.py
@@ -1,7 +1,5 @@
from __future__ import unicode_literals
-import warnings
-
from django import forms
from django.utils import six
from django.utils.translation import ugettext_lazy as _
@@ -34,10 +32,6 @@ def __init__(self, **kwargs):
# defaults (e.g., allow None).
self.srid = kwargs.pop('srid', None)
self.geom_type = kwargs.pop('geom_type', self.geom_type)
- if 'null' in kwargs:
- kwargs.pop('null', True)
- warnings.warn("Passing 'null' keyword argument to GeometryField is deprecated.",
- DeprecationWarning, stacklevel=2)
super(GeometryField, self).__init__(**kwargs)
self.widget.attrs['geom_type'] = self.geom_type
View
5 django/contrib/gis/gdal/tests/test_driver.py
@@ -1,6 +1,7 @@
+import unittest
+from unittest import skipUnless
+
from django.contrib.gis.gdal import HAS_GDAL
-from django.utils import unittest
-from django.utils.unittest import skipUnless
if HAS_GDAL:
from django.contrib.gis.gdal import Driver, OGRException
View
4 django/contrib/gis/gdal/tests/test_ds.py
@@ -1,9 +1,9 @@
import os
+import unittest
+from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geometry.test_data import get_ds_file, TestDS, TEST_DATA
-from django.utils import unittest
-from django.utils.unittest import skipUnless
if HAS_GDAL:
from django.contrib.gis.gdal import DataSource, Envelope, OGRGeometry, OGRException, OGRIndexError, GDAL_VERSION
View
7 django/contrib/gis/gdal/tests/test_envelope.py
@@ -1,6 +1,7 @@
+import unittest
+from unittest import skipUnless
+
from django.contrib.gis.gdal import HAS_GDAL
-from django.utils import unittest
-from django.utils.unittest import skipUnless
if HAS_GDAL:
from django.contrib.gis.gdal import Envelope, OGRException
@@ -17,7 +18,7 @@ class EnvelopeTest(unittest.TestCase):
def setUp(self):
self.e = Envelope(0, 0, 5, 5)
-
+
def test01_init(self):
"Testing Envelope initilization."
e1 = Envelope((0, 0, 5, 5))
View
4 django/contrib/gis/gdal/tests/test_geom.py
@@ -4,12 +4,12 @@
from django.utils.six.moves import cPickle as pickle
except ImportError:
import pickle
+import unittest
+from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geometry.test_data import TestDataMixin
from django.utils.six.moves import xrange
-from django.utils import unittest
-from django.utils.unittest import skipUnless
if HAS_GDAL:
from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType,
View
5 django/contrib/gis/gdal/tests/test_srs.py
@@ -1,6 +1,7 @@
+import unittest
+from unittest import skipUnless
+
from django.contrib.gis.gdal import HAS_GDAL
-from django.utils import unittest
-from django.utils.unittest import skipUnless
if HAS_GDAL:
from django.contrib.gis.gdal import SpatialReference, CoordTransform, OGRException, SRSException
View
5 django/contrib/gis/geoip/tests.py
@@ -2,11 +2,12 @@
from __future__ import unicode_literals
import os
+import unittest
+from unittest import skipUnless
+
from django.conf import settings
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.geoip import HAS_GEOIP
-from django.utils import unittest
-from django.utils.unittest import skipUnless
from django.utils import six
View
4 django/contrib/gis/geos/tests/test_geos.py
@@ -3,6 +3,8 @@
import ctypes
import json
import random
+import unittest
+from unittest import skipUnless
from binascii import a2b_hex, b2a_hex
from io import BytesIO
@@ -14,8 +16,6 @@
from django.utils.encoding import force_bytes
from django.utils import six
from django.utils.six.moves import xrange
-from django.utils import unittest
-from django.utils.unittest import skipUnless
from .. import HAS_GEOS
View
4 django/contrib/gis/geos/tests/test_geos_mutation.py
@@ -2,8 +2,8 @@
# Modified from original contribution by Aryeh Leib Taurog, which was
# released under the New BSD license.
-from django.utils import unittest
-from django.utils.unittest import skipUnless
+import unittest
+from unittest import skipUnless
from .. import HAS_GEOS
View
2  django/contrib/gis/geos/tests/test_io.py
@@ -2,9 +2,9 @@
import binascii
import unittest
+from unittest import skipUnless
from django.contrib.gis import memoryview
-from django.utils.unittest import skipUnless
from ..import HAS_GEOS
View
4 django/contrib/gis/geos/tests/test_mutable_list.py
@@ -3,9 +3,11 @@
#
# Modified from original contribution by Aryeh Leib Taurog, which was
# released under the New BSD license.
+
+import unittest
+
from django.contrib.gis.geos.mutable_list import ListMixin
from django.utils import six
-from django.utils import unittest
class UserListA(ListMixin):
View
3  django/contrib/gis/tests/distapp/tests.py
@@ -1,5 +1,7 @@
from __future__ import absolute_import
+from unittest import skipUnless
+
from django.db import connection
from django.db.models import Q
from django.contrib.gis.geos import HAS_GEOS
@@ -8,7 +10,6 @@
HAS_SPATIAL_DB, mysql, oracle, postgis, spatialite, no_oracle, no_spatialite
)
from django.test import TestCase
-from django.utils.unittest import skipUnless
if HAS_GEOS and HAS_SPATIAL_DB:
from django.contrib.gis.geos import GEOSGeometry, LineString
View
2  django/contrib/gis/tests/geo3d/tests.py
@@ -2,13 +2,13 @@
import os
import re
+from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import postgis
from django.test import TestCase
from django.utils._os import upath
-from django.utils.unittest import skipUnless
if HAS_GEOS:
from django.contrib.gis.db.models import Union, Extent3D
View
3  django/contrib/gis/tests/geoadmin/tests.py
@@ -1,9 +1,10 @@
from __future__ import absolute_import
+from unittest import skipUnless
+
from django.test import TestCase
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
-from django.utils.unittest import skipUnless
if HAS_GEOS and HAS_SPATIAL_DB:
from django.contrib.gis import admin
View
2  django/contrib/gis/tests/geoapp/test_feeds.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
+from unittest import skipUnless
from xml.dom import minidom
from django.conf import settings
@@ -7,7 +8,6 @@
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
from django.test import TestCase
-from django.utils.unittest import skipUnless
if HAS_GEOS:
from .models import City
View
2  django/contrib/gis/tests/geoapp/test_regress.py
@@ -2,6 +2,7 @@
from __future__ import absolute_import, unicode_literals
from datetime import datetime
+from unittest import skipUnless
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import no_mysql, no_spatialite
@@ -9,7 +10,6 @@
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
from django.db.models import Count, Min
from django.test import TestCase
-from django.utils.unittest import skipUnless
if HAS_GEOS:
from .models import City, PennsylvaniaCity, State, Truth
View
2  django/contrib/gis/tests/geoapp/test_sitemaps.py
@@ -1,6 +1,7 @@
from __future__ import absolute_import
from io import BytesIO
+from unittest import skipUnless
from xml.dom import minidom
import zipfile
@@ -9,7 +10,6 @@
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
from django.contrib.sites.models import Site
from django.test import TestCase
-from django.utils.unittest import skipUnless
if HAS_GEOS:
from .models import City, Country
View
5 django/contrib/gis/tests/geoapp/tests.py
@@ -1,6 +1,8 @@
from __future__ import absolute_import
import re
+import unittest
+from unittest import skipUnless
from django.db import connection
from django.contrib.gis import gdal
@@ -9,8 +11,7 @@
no_mysql, no_oracle, no_spatialite,
mysql, oracle, postgis, spatialite)
from django.test import TestCase
-from django.utils import six, unittest
-from django.utils.unittest import skipUnless
+from django.utils import six
if HAS_GEOS:
from django.contrib.gis.geos import (fromstr, GEOSGeometry,
View
2  django/contrib/gis/tests/geogapp/tests.py
@@ -4,6 +4,7 @@
from __future__ import absolute_import
import os
+from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geos import HAS_GEOS
@@ -11,7 +12,6 @@
from django.contrib.gis.tests.utils import postgis
from django.test import TestCase
from django.utils._os import upath
-from django.utils.unittest import skipUnless
if HAS_GEOS:
from .models import City, County, Zipcode
View
2  django/contrib/gis/tests/inspectapp/tests.py
@@ -1,13 +1,13 @@
from __future__ import absolute_import
import os
+from unittest import skipUnless
from django.db import connections
from django.test import TestCase
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geometry.test_data import TEST_DATA
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
-from django.utils.unittest import skipUnless
if HAS_GDAL:
from django.contrib.gis.gdal import Driver
View
6 django/contrib/gis/tests/layermap/tests.py
@@ -1,17 +1,17 @@
# coding: utf-8
from __future__ import absolute_import, unicode_literals
-import os
from copy import copy
from decimal import Decimal
+import os
+import unittest
+from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB, mysql
from django.db import router
from django.conf import settings
from django.test import TestCase
-from django.utils import unittest
-from django.utils.unittest import skipUnless
from django.utils._os import upath
if HAS_GDAL:
View
3  django/contrib/gis/tests/relatedapp/tests.py
@@ -1,9 +1,10 @@
from __future__ import absolute_import
+from unittest import skipUnless
+
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB, mysql, oracle, no_mysql, no_oracle, no_spatialite
from django.test import TestCase
-from django.utils.unittest import skipUnless
if HAS_GEOS:
from django.contrib.gis.db.models import Collect, Count, Extent, F, Union
View
7 django/contrib/gis/tests/test_geoforms.py
@@ -1,15 +1,16 @@
+from unittest import skipUnless
+
from django.forms import ValidationError
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.tests.utils import HAS_SPATIALREFSYS
from django.test import SimpleTestCase
from django.utils import six
-from django.utils.unittest import skipUnless
-
if HAS_SPATIALREFSYS:
from django.contrib.gis import forms
from django.contrib.gis.geos import GEOSGeometry
+
@skipUnless(HAS_GDAL and HAS_SPATIALREFSYS, "GeometryFieldTest needs gdal support and a spatial database")
class GeometryFieldTest(SimpleTestCase):
@@ -143,7 +144,7 @@ def assertMapWidget(self, form_instance):
def assertTextarea(self, geom, rendered):
"""Makes sure the wkt and a textarea are in the content"""
-
+
self.assertIn('<textarea ', rendered)
self.assertIn('required', rendered)
self.assertIn(geom.wkt, rendered)
View
3  django/contrib/gis/tests/test_measure.py
@@ -3,8 +3,9 @@
and conversions. Here are some tests.
"""
+import unittest
+
from django.contrib.gis.measure import Distance, Area, D, A
-from django.utils import unittest
class DistanceTest(unittest.TestCase):
View
3  django/contrib/gis/tests/test_spatialrefsys.py
@@ -1,8 +1,9 @@
+import unittest
+
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.tests.utils import (no_mysql, oracle, postgis,
spatialite, HAS_SPATIALREFSYS, SpatialRefSys)
from django.utils import six
-from django.utils import unittest
test_srs = ({'srid' : 4326,
View
2  django/contrib/humanize/tests.py
@@ -1,6 +1,7 @@
from __future__ import unicode_literals
import datetime
from decimal import Decimal
+from unittest import skipIf
try:
import pytz
@@ -17,7 +18,6 @@
from django.utils import translation
from django.utils.translation import ugettext as _
from django.utils import tzinfo
-from django.utils.unittest import skipIf
from i18n import TransRealMixin
View
3  django/contrib/messages/tests/base.py
@@ -1,3 +1,5 @@
+from unittest import skipIf
+
from django import http
from django.conf import settings, global_settings
from django.contrib.messages import constants, utils, get_level, set_level
@@ -7,7 +9,6 @@
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from django.utils.translation import ugettext_lazy
-from django.utils.unittest import skipIf
def skipUnlessAuthIsInstalled(func):
View
3  django/contrib/messages/tests/test_middleware.py
@@ -1,6 +1,7 @@
+import unittest
+
from django import http
from django.contrib.messages.middleware import MessageMiddleware
-from django.utils import unittest
class MiddlewareTest(unittest.TestCase):
View
7 django/contrib/sessions/middleware.py
@@ -6,10 +6,13 @@
from django.utils.importlib import import_module
class SessionMiddleware(object):
- def process_request(self, request):
+ def __init__(self):
engine = import_module(settings.SESSION_ENGINE)
+ self.SessionStore = engine.SessionStore
+
+ def process_request(self, request):
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
- request.session = engine.SessionStore(session_key)
+ request.session = self.SessionStore(session_key)
def process_response(self, request, response):
"""
View
2  django/contrib/sessions/tests.py
@@ -4,6 +4,7 @@
import shutil
import string
import tempfile
+import unittest
import warnings
from django.conf import settings
@@ -22,7 +23,6 @@
from django.test.utils import override_settings, patch_logger
from django.utils import six
from django.utils import timezone
-from django.utils import unittest
from django.contrib.sessions.exceptions import InvalidSessionKey
View
3  django/contrib/sitemaps/tests/test_flatpages.py
@@ -1,7 +1,8 @@
from __future__ import unicode_literals
+from unittest import skipUnless
+
from django.conf import settings
-from django.utils.unittest import skipUnless
from .base import SitemapTestsBase
View
2  django/contrib/sitemaps/tests/test_http.py
@@ -2,13 +2,13 @@
import os
from datetime import date
+from unittest import skipUnless
from django.conf import settings
from django.contrib.sitemaps import Sitemap, GenericSitemap
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.test.utils import override_settings
-from django.utils.unittest import skipUnless
from django.utils.formats import localize
from django.utils._os import upath
from django.utils.translation import activate, deactivate
View
17 django/contrib/sitemaps/views.py
@@ -1,4 +1,3 @@
-import warnings
from functools import wraps
from django.contrib.sites.models import get_current_site
@@ -19,13 +18,7 @@ def inner(request, *args, **kwargs):
@x_robots_tag
def index(request, sitemaps,
template_name='sitemap_index.xml', content_type='application/xml',
- sitemap_url_name='django.contrib.sitemaps.views.sitemap',
- mimetype=None):
-
- if mimetype:
- warnings.warn("The mimetype keyword argument is deprecated, use "
- "content_type instead", DeprecationWarning, stacklevel=2)
- content_type = mimetype
+ sitemap_url_name='django.contrib.sitemaps.views.sitemap'):
req_protocol = 'https' if request.is_secure() else 'http'
req_site = get_current_site(request)
@@ -47,13 +40,7 @@ def index(request, sitemaps,
@x_robots_tag
def sitemap(request, sitemaps, section=None,
- template_name='sitemap.xml', content_type='application/xml',
- mimetype=None):
-
- if mimetype:
- warnings.warn("The mimetype keyword argument is deprecated, use "
- "content_type instead", DeprecationWarning, stacklevel=2)
- content_type = mimetype
+ template_name='sitemap.xml', content_type='application/xml'):
req_protocol = 'https' if request.is_secure() else 'http'
req_site = get_current_site(request)
View
1  django/core/files/storage.py
@@ -231,6 +231,7 @@ def _save(self, name, content):
return name
def delete(self, name):
+ assert name, "The name argument is not allowed to be empty."
name = self.path(name)
# If the file exists, delete it from the filesystem.
# Note that there is a race between os.path.exists and os.remove:
View
11 django/core/management/commands/cleanup.py
@@ -1,11 +0,0 @@
-import warnings
-
-from django.contrib.sessions.management.commands import clearsessions
-
-
-class Command(clearsessions.Command):
- def handle_noargs(self, **options):
- warnings.warn(
- "The `cleanup` command has been deprecated in favor of `clearsessions`.",
- DeprecationWarning)
- super(Command, self).handle_noargs(**options)
View
4 django/db/__init__.py
@@ -49,7 +49,7 @@ class DefaultBackendProxy(object):
@cached_property
def _backend(self):
warnings.warn("Accessing django.db.backend is deprecated.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
return load_backend(connections[DEFAULT_DB_ALIAS].settings_dict['ENGINE'])
def __getattr__(self, item):
@@ -66,7 +66,7 @@ def __delattr__(self, name):
def close_connection(**kwargs):
warnings.warn(
"close_connection is superseded by close_old_connections.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
# Avoid circular imports
from django.db import transaction
for conn in connections:
View
34 django/db/backends/__init__.py
@@ -204,7 +204,7 @@ def _savepoint_commit(self, sid):
def _savepoint_allowed(self):
# Savepoints cannot be created outside a transaction
- return self.features.uses_savepoints and not self.autocommit
+ return self.features.uses_savepoints and not self.get_autocommit()
##### Generic savepoint management methods #####
@@ -279,15 +279,13 @@ def enter_transaction_management(self, managed=True, forced=False):
"""
self.validate_no_atomic_block()
- self.ensure_connection()
-
self.transaction_state.append(managed)
if not managed and self.is_dirty() and not forced:
self.commit()
self.set_clean()
- if managed == self.autocommit:
+ if managed == self.get_autocommit():
self.set_autocommit(not managed)
def leave_transaction_management(self):
@@ -298,8 +296,6 @@ def leave_transaction_management(self):
"""
self.validate_no_atomic_block()
- self.ensure_connection()
-
if self.transaction_state:
del self.transaction_state[-1]
else:
@@ -313,14 +309,21 @@ def leave_transaction_management(self):
if self._dirty:
self.rollback()
- if managed == self.autocommit:
+ if managed == self.get_autocommit():
self.set_autocommit(not managed)
raise TransactionManagementError(
"Transaction managed block ended with pending COMMIT/ROLLBACK")
- if managed == self.autocommit:
+ if managed == self.get_autocommit():
self.set_autocommit(not managed)
+ def get_autocommit(self):
+ """
+ Check the autocommit state.
+ """
+ self.ensure_connection()
+ return self.autocommit
+
def set_autocommit(self, autocommit):
"""
Enable or disable autocommit.
@@ -330,13 +333,22 @@ def set_autocommit(self, autocommit):
self._set_autocommit(autocommit)
self.autocommit = autocommit
+ def get_rollback(self):
+ """
+ Get the "needs rollback" flag -- for *advanced use* only.
+ """
+ if not self.in_atomic_block:
+ raise TransactionManagementError(
+ "The rollback flag doesn't work outside of an 'atomic' block.")
+ return self.needs_rollback
+
def set_rollback(self, rollback):
"""
Set or unset the "needs rollback" flag -- for *advanced use* only.
"""
if not self.in_atomic_block:
raise TransactionManagementError(
- "needs_rollback doesn't work outside of an 'atomic' block.")
+ "The rollback flag doesn't work outside of an 'atomic' block.")
self.needs_rollback = rollback
def validate_no_atomic_block(self):
@@ -370,7 +382,7 @@ def set_dirty(self):
to decide in a managed block of code to decide whether there are open
changes waiting for commit.
"""
- if not self.autocommit:
+ if not self.get_autocommit():
self._dirty = True
def set_clean(self):
@@ -436,7 +448,7 @@ def close_if_unusable_or_obsolete(self):
if self.connection is not None:
# If the application didn't restore the original autocommit setting,
# don't take chances, drop the connection.
- if self.autocommit != self.settings_dict['AUTOCOMMIT']:
+ if self.get_autocommit() != self.settings_dict['AUTOCOMMIT']:
self.close()
return
View
2  django/db/backends/creation.py
@@ -468,7 +468,7 @@ def set_autocommit(self):
"""
warnings.warn(
"set_autocommit was moved from BaseDatabaseCreation to "
- "BaseDatabaseWrapper.", PendingDeprecationWarning, stacklevel=2)
+ "BaseDatabaseWrapper.", DeprecationWarning, stacklevel=2)
return self.connection.set_autocommit(True)
def sql_table_creation_suffix(self):
View
2  django/db/backends/mysql/base.py
@@ -288,7 +288,7 @@ def last_executed_query(self, cursor, sql, params):
# With MySQLdb, cursor objects have an (undocumented) "_last_executed"
# attribute where the exact query sent to the database is saved.
# See MySQLdb/cursors.py in the source distribution.
- return force_text(cursor._last_executed, errors='replace')
+ return force_text(getattr(cursor, '_last_executed', None), errors='replace')
def no_limit_value(self):
# 2**64 - 1, as recommended by the MySQL documentation
View
10 django/db/backends/sqlite3/base.py
@@ -79,14 +79,8 @@ def decoder(conv_func):
Database.register_adapter(datetime.datetime, adapt_datetime_with_timezone_support)
Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal)
-if Database.version_info >= (2, 4, 1):
- # Starting in 2.4.1, the str type is not accepted anymore, therefore,
- # we convert all str objects to Unicode
- # As registering a adapter for a primitive type causes a small
- # slow-down, this adapter is only registered for sqlite3 versions
- # needing it (Python 2.6 and up).
- Database.register_adapter(str, lambda s: s.decode('utf-8'))
- Database.register_adapter(SafeBytes, lambda s: s.decode('utf-8'))
+Database.register_adapter(str, lambda s: s.decode('utf-8'))
+Database.register_adapter(SafeBytes, lambda s: s.decode('utf-8'))
class DatabaseFeatures(BaseDatabaseFeatures):
# SQLite cannot handle us only partially reading from a cursor's result set
View
2  django/db/models/fields/files.py
@@ -96,6 +96,8 @@ def save(self, name, content, save=True):
save.alters_data = True
def delete(self, save=True):
+ if not self:
+ return
# Only close the file if it's already open, which we know by the
# presence of self._file
if hasattr(self, '_file'):
View
13 django/db/models/fields/related.py
@@ -89,7 +89,6 @@ def do_pending_lookups(sender, **kwargs):
signals.class_prepared.connect(do_pending_lookups)
-#HACK
class RelatedField(Field):
def db_type(self, connection):
'''By default related field will not have a column
@@ -142,8 +141,8 @@ def related_query_name(self):
class RenameRelatedObjectDescriptorMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', PendingDeprecationWarning),
- ('get_prefetch_query_set', 'get_prefetch_queryset', PendingDeprecationWarning),
+ ('get_query_set', 'get_queryset', DeprecationWarning),
+ ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
)
@@ -1166,7 +1165,7 @@ def deconstruct(self):
rel = self.rel
if self.rel.field_name:
kwargs['to_field'] = self.rel.field_name
- if isinstance(self.rel.to, basestring):
+ if isinstance(self.rel.to, six.string_types):
kwargs['to'] = self.rel.to
else:
kwargs['to'] = "%s.%s" % (self.rel.to._meta.app_label, self.rel.to._meta.object_name)
@@ -1367,9 +1366,7 @@ def __init__(self, to, db_constraint=True, **kwargs):
assert not to._meta.abstract, "%s cannot define a relation with abstract class %s" % (self.__class__.__name__, to._meta.object_name)
except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT
assert isinstance(to, six.string_types), "%s(%r) is invalid. First parameter to ManyToManyField must be either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT)
- # Python 2.6 and earlier require dictionary keys to be of str type,
- # not unicode and class names must be ASCII (in Python 2.x), so we
- # forcibly coerce it here (breaks early if there's a problem).
+ # Class names must be ASCII in Python 2.x, so we forcibly coerce it here to break early if there's a problem.
to = str(to)
kwargs['verbose_name'] = kwargs.get('verbose_name', None)
@@ -1397,7 +1394,7 @@ def deconstruct(self):
del kwargs['help_text']
# Rel needs more work.
rel = self.rel
- if isinstance(self.rel.to, basestring):
+ if isinstance(self.rel.to, six.string_types):
kwargs['to'] = self.rel.to
else:
kwargs['to'] = "%s.%s" % (self.rel.to._meta.app_label, self.rel.to._meta.object_name)
View
4 django/db/models/manager.py
@@ -50,8 +50,8 @@ def ensure_default_manager(sender, **kwargs):
class RenameManagerMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', PendingDeprecationWarning),
- ('get_prefetch_query_set', 'get_prefetch_queryset', PendingDeprecationWarning),
+ ('get_query_set', 'get_queryset', DeprecationWarning),
+ ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
)
View
8 django/db/models/options.py
@@ -138,7 +138,7 @@ def module_name(self):
"""
warnings.warn(
"Options.module_name has been deprecated in favor of model_name",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
return self.model_name
def _prepare(self, model):
@@ -429,7 +429,7 @@ def get_add_permission(self):
warnings.warn(
"`Options.get_add_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
return 'add_%s' % self.model_name
def get_change_permission(self):
@@ -440,7 +440,7 @@ def get_change_permission(self):
warnings.warn(
"`Options.get_change_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
return 'change_%s' % self.model_name
def get_delete_permission(self):
@@ -451,7 +451,7 @@ def get_delete_permission(self):
warnings.warn(
"`Options.get_delete_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
return 'delete_%s' % self.model_name
def get_all_related_objects(self, local_only=False, include_hidden=False,
View
9 django/db/models/query.py
@@ -5,7 +5,6 @@
import copy
import itertools
import sys
-import warnings
from django.conf import settings
from django.core import exceptions
@@ -648,10 +647,6 @@ def select_related(self, *fields, **kwargs):
If select_related(None) is called, the list is cleared.
"""
- if 'depth' in kwargs:
- warnings.warn('The "depth" keyword argument has been deprecated.\n'
- 'Use related field names instead.', DeprecationWarning, stacklevel=2)
- depth = kwargs.pop('depth', 0)
if kwargs:
raise TypeError('Unexpected keyword arguments to select_related: %s'
% (list(kwargs),))
@@ -659,13 +654,9 @@ def select_related(self, *fields, **kwargs):
if fields == (None,):
obj.query.select_related = False
elif fields:
- if depth:
- raise TypeError('Cannot pass both "depth" and fields to select_related()')
obj.query.add_select_related(fields)
else:
obj.query.select_related = True
- if depth:
- obj.query.max_depth = depth
return obj
def prefetch_related(self, *lookups):
View
26 django/db/transaction.py
@@ -101,19 +101,19 @@ def set_clean(using=None):
def is_managed(using=None):
warnings.warn("'is_managed' is deprecated.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
def managed(flag=True, using=None):
warnings.warn("'managed' no longer serves a purpose.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
def commit_unless_managed(using=None):
warnings.warn("'commit_unless_managed' is now a no-op.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
def rollback_unless_managed(using=None):
warnings.warn("'rollback_unless_managed' is now a no-op.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
###############
# Public APIs #
@@ -123,7 +123,7 @@ def get_autocommit(using=None):
"""
Get the autocommit status of the connection.
"""
- return get_connection(using).autocommit
+ return get_connection(using).get_autocommit()
def set_autocommit(autocommit, using=None):
"""
@@ -175,7 +175,7 @@ def get_rollback(using=None):
"""
Gets the "needs rollback" flag -- for *advanced use* only.
"""
- return get_connection(using).needs_rollback
+ return get_connection(using).get_rollback()
def set_rollback(rollback, using=None):
"""
@@ -229,15 +229,11 @@ def __init__(self, using, savepoint):
def __enter__(self):
connection = get_connection(self.using)
- # Ensure we have a connection to the database before testing
- # autocommit status.
- connection.ensure_connection()
-
if not connection.in_atomic_block:
# Reset state when entering an outermost atomic block.
connection.commit_on_exit = True
connection.needs_rollback = False
- if not connection.autocommit:
+ if not connection.get_autocommit():
# Some database adapters (namely sqlite3) don't handle
# transactions and savepoints properly when autocommit is off.
# Turning autocommit back on isn't an option; it would trigger
@@ -430,7 +426,7 @@ def autocommit(using=None):
your settings file and want the default behavior in some view functions.
"""
warnings.warn("autocommit is deprecated in favor of set_autocommit.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
def entering(using):
enter_transaction_management(managed=False, using=using)
@@ -448,7 +444,7 @@ def commit_on_success(using=None):
control in Web apps.
"""
warnings.warn("commit_on_success is deprecated in favor of atomic.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
def entering(using):
enter_transaction_management(using=using)
@@ -478,7 +474,7 @@ def commit_manually(using=None):
themselves.
"""
warnings.warn("commit_manually is deprecated in favor of set_autocommit.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
def entering(using):
enter_transaction_management(using=using)
@@ -500,7 +496,7 @@ def commit_on_success_unless_managed(using=None, savepoint=False):
legacy behavior.
"""
connection = get_connection(using)
- if connection.autocommit or connection.in_atomic_block:
+ if connection.get_autocommit() or connection.in_atomic_block:
return atomic(using, savepoint)
else:
def entering(using):
View
9 django/db/utils.py
@@ -85,12 +85,7 @@ def __exit__(self, exc_type, exc_value, traceback):
):
db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
if issubclass(exc_type, db_exc_type):
- # Under Python 2.6, exc_value can still be a string.
- try:
- args = tuple(exc_value.args)
- except AttributeError:
- args = (exc_value,)
- dj_exc_value = dj_exc_type(*args)
+ dj_exc_value = dj_exc_type(*exc_value.args)
dj_exc_value.__cause__ = exc_value
# Only set the 'errors_occurred' flag for errors that may make
# the connection unusable.
@@ -174,7 +169,7 @@ def ensure_defaults(self, alias):
if settings.TRANSACTIONS_MANAGED:
warnings.warn(
"TRANSACTIONS_MANAGED is deprecated. Use AUTOCOMMIT instead.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
conn.setdefault('AUTOCOMMIT', False)
conn.setdefault('AUTOCOMMIT', True)
conn.setdefault('ENGINE', 'django.db.backends.dummy')
View
2  django/forms/forms.py
@@ -352,7 +352,7 @@ def changed_data(self):
if hasattr(field.widget, '_has_changed'):
warnings.warn("The _has_changed method on widgets is deprecated,"
" define it at field level instead.",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
if field.widget._has_changed(initial_value, data_value):
self._changed_data.append(name)
elif field._has_changed(initial_value, data_value):
View
6 django/forms/models.py
@@ -260,7 +260,7 @@ def __new__(cls, name, bases, attrs):
warnings.warn("Creating a ModelForm without either the 'fields' attribute "
"or the 'exclude' attribute is deprecated - form %s "
"needs updating" % name,
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
</