diff --git a/django/contrib/sitemaps/__init__.py b/django/contrib/sitemaps/__init__.py index 747cd1d6af..781ad8995d 100644 --- a/django/contrib/sitemaps/__init__.py +++ b/django/contrib/sitemaps/__init__.py @@ -80,10 +80,7 @@ class Sitemap(object): except Site.DoesNotExist: pass if site is None: - raise ImproperlyConfigured("In order to use Sitemaps " - "you must either use the sites framework " - "or pass in a Site or RequestSite object " - "in your view code.") + raise ImproperlyConfigured("To use sitemaps, either enable the sites framework or pass a Site/RequestSite object in your view.") domain = site.domain urls = [] diff --git a/django/test/testcases.py b/django/test/testcases.py index af455a2872..b5e1dc0418 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -411,15 +411,14 @@ class SimpleTestCase(ut2.TestCase): def assertHTMLEqual(self, html1, html2, msg=None): """ - Asserts that two html snippets are semantically the same, - e.g. whitespace in most cases is ignored, attribute ordering is not - significant. The passed in arguments must be valid HTML. - + Asserts that two HTML snippets are semantically the same. + Whitespace in most cases is ignored, and attribute ordering is not + significant. The passed-in arguments must be valid HTML. """ dom1 = assert_and_parse_html(self, html1, msg, - u'First argument is not valid html:') + u'First argument is not valid HTML:') dom2 = assert_and_parse_html(self, html2, msg, - u'Second argument is not valid html:') + u'Second argument is not valid HTML:') if dom1 != dom2: standardMsg = '%s != %s' % ( @@ -433,9 +432,9 @@ class SimpleTestCase(ut2.TestCase): def assertHTMLNotEqual(self, html1, html2, msg=None): """Asserts that two HTML snippets are not semantically equivalent.""" dom1 = assert_and_parse_html(self, html1, msg, - u'First argument is not valid html:') + u'First argument is not valid HTML:') dom2 = assert_and_parse_html(self, html2, msg, - u'Second argument is not valid html:') + u'Second argument is not valid HTML:') if dom1 == dom2: standardMsg = '%s == %s' % ( @@ -625,9 +624,9 @@ class TransactionTestCase(SimpleTestCase): content = response.content if html: content = assert_and_parse_html(self, content, None, - u"Response's content is not valid html:") + u"Response's content is not valid HTML:") text = assert_and_parse_html(self, text, None, - u"Second argument is not valid html:") + u"Second argument is not valid HTML:") real_count = content.count(text) if count is not None: self.assertEqual(real_count, count, @@ -661,9 +660,9 @@ class TransactionTestCase(SimpleTestCase): content = response.content if html: content = assert_and_parse_html(self, content, None, - u'Response\'s content is no valid html:') + u'Response\'s content is not valid HTML:') text = assert_and_parse_html(self, text, None, - u'Second argument is no valid html:') + u'Second argument is not valid HTML:') self.assertEqual(content.count(text), 0, msg_prefix + "Response should not contain '%s'" % text) @@ -721,7 +720,7 @@ class TransactionTestCase(SimpleTestCase): def assertTemplateUsed(self, response=None, template_name=None, msg_prefix=''): """ Asserts that the template with the provided name was used in rendering - the response. Also useable as context manager. + the response. Also usable as context manager. """ if response is None and template_name is None: raise TypeError(u'response and/or template_name argument must be provided') @@ -729,7 +728,7 @@ class TransactionTestCase(SimpleTestCase): if msg_prefix: msg_prefix += ": " - # use assertTemplateUsed as context manager + # Use assertTemplateUsed as context manager. if not hasattr(response, 'templates') or (response is None and template_name): if response: template_name = response @@ -748,7 +747,7 @@ class TransactionTestCase(SimpleTestCase): def assertTemplateNotUsed(self, response=None, template_name=None, msg_prefix=''): """ Asserts that the template with the provided name was NOT used in - rendering the response. Also useable as context manager. + rendering the response. Also usable as context manager. """ if response is None and template_name is None: raise TypeError(u'response and/or template_name argument must be provided') @@ -756,7 +755,7 @@ class TransactionTestCase(SimpleTestCase): if msg_prefix: msg_prefix += ": " - # use assertTemplateUsed as context manager + # Use assertTemplateUsed as context manager. if not hasattr(response, 'templates') or (response is None and template_name): if response: template_name = response diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt index 4347c680a8..5ed927a9df 100644 --- a/docs/intro/tutorial03.txt +++ b/docs/intro/tutorial03.txt @@ -365,11 +365,11 @@ special: It's just a normal view. You normally won't have to bother with writing 404 views. If you don't set ``handler404``, the built-in view :func:`django.views.defaults.page_not_found` -is used by default. In this case, you still have one obligation: To create a +is used by default. In this case, you still have one obligation: create a ``404.html`` template in the root of your template directory. The default 404 view will use that template for all 404 errors. If :setting:`DEBUG` is set to ``False`` (in your settings module) and if you didn't create a ``404.html`` -file, an ``Http500`` is raised instead. So remember to create a ``404.html``. +file, an ``Http500`` is raised instead. So remember to create a ``404.html``. A couple more things to note about 404 views: diff --git a/docs/ref/contrib/sitemaps.txt b/docs/ref/contrib/sitemaps.txt index ac9f8abac4..374fd6c55a 100644 --- a/docs/ref/contrib/sitemaps.txt +++ b/docs/ref/contrib/sitemaps.txt @@ -310,7 +310,7 @@ index will reflect that. .. versionadded:: 1.4 -If you are not using the vanilla sitemap view -- for example, if it is wrapped +If you're not using the vanilla sitemap view -- for example, if it's wrapped with a caching decorator -- you must name your sitemap view and pass ``sitemap_url_name`` to the index view:: diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 3f5840bfd5..3010cd020c 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -1002,7 +1002,7 @@ For example:: .. versionadded:: 1.4 As with the :djadmin:`startapp` command, the ``--template`` option lets you -specify a directory, file path, or URL of a custom project template. See the +specify a directory, file path or URL of a custom project template. See the :djadmin:`startapp` documentation for details of supported project template formats. diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt index d57dbc9adc..99e2ae3838 100644 --- a/docs/ref/middleware.txt +++ b/docs/ref/middleware.txt @@ -96,17 +96,21 @@ browsers). It is suggested to place this first in the middleware list, so that the compression of the response content is the last thing that happens. -It will not compress content bodies less than 200 bytes long, when the -``Content-Encoding`` header is already set, or when the browser does not send -an ``Accept-Encoding`` header containing ``gzip``. +It will NOT compress content if any of the following are true: -Content will also not be compressed when the browser is Internet Explorer and -the ``Content-Type`` header contains ``javascript`` or starts with anything -other than ``text/``. This is done to overcome a bug present in early versions -of Internet Explorer which caused decompression not to be performed on certain -content types. +* The content body is less than 200 bytes long. -GZip compression can be applied to individual views using the +* The response has already set the ``Content-Encoding`` header. + +* The request (the browser) hasn't sent an ``Accept-Encoding`` header + containing ``gzip``. + +* The request is from Internet Explorer and the ``Content-Type`` header + contains ``javascript`` or starts with anything other than ``text/``. + We do this to avoid a bug in early versions of IE that caused decompression + not to be performed on certain content types. + +You can apply GZip compression to individual views using the :func:`~django.views.decorators.http.gzip_page()` decorator. Conditional GET middleware diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 85d43ceb51..afee499830 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -2232,7 +2232,7 @@ This template tag works on links prefixed with ``http://``, ``https://``, or It also supports domain-only links ending in one of the original top level domains (``.com``, ``.edu``, ``.gov``, ``.int``, ``.mil``, ``.net``, and -``.org``). For example, ``djangoproject.com`` gets converted too. +``.org``). For example, ``djangoproject.com`` gets converted. .. versionchanged:: 1.4 @@ -2240,7 +2240,7 @@ Until Django 1.4, only the ``.com``, ``.net`` and ``.org`` suffixes were supported for domain-only links. Links can have trailing punctuation (periods, commas, close-parens) and leading -punctuation (opening parens) and ``urlize`` will still do the right thing. +punctuation (opening parens), and ``urlize`` will still do the right thing. Links generated by ``urlize`` have a ``rel="nofollow"`` attribute added to them. diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt index 664b9ea28d..464ba571a5 100644 --- a/docs/releases/1.4.txt +++ b/docs/releases/1.4.txt @@ -480,15 +480,15 @@ HTML comparisons in tests The :class:`~django.test.testcase.TestCase` base class now has some helpers to compare HTML without tripping over irrelevant differences in whitespace, -argument quoting and ordering, and closing of self-closing tags. HTML can -either be compared directly with the new +argument quoting/ordering and closing of self-closing tags. You can either +compare HTML directly with the new :meth:`~django.test.testcase.TestCase.assertHTMLEqual` and :meth:`~django.test.testcase.TestCase.assertHTMLNotEqual` assertions, or use the ``html=True`` flag with :meth:`~django.test.testcase.TestCase.assertContains` and -:meth:`~django.test.testcase.TestCase.assertNotContains` to test if the test +:meth:`~django.test.testcase.TestCase.assertNotContains` to test whether the client's response contains a given HTML fragment. See the :ref:`assertion -documentation` for more information. +documentation` for more. Minor features ~~~~~~~~~~~~~~ @@ -571,11 +571,11 @@ Django 1.4 also includes several smaller improvements worth noting: * The MySQL database backend can now make use of the savepoint feature implemented by MySQL version 5.0.3 or newer with the InnoDB storage engine. -* It is now possible to pass initial values to the model forms that are part of - both model formsets and inline model formset as returned from factory +* It's now possible to pass initial values to the model forms that are part of + both model formsets and inline model formsets as returned from factory functions ``modelformset_factory`` and ``inlineformset_factory`` respectively just like with regular formsets. However, initial values only apply to extra - forms i.e. those which are not bound to an existing model instance. + forms, i.e. those which are not bound to an existing model instance. * The sitemaps framework can now handle HTTPS links using the new :attr:`Sitemap.protocol ` class @@ -800,8 +800,8 @@ to pysqlite). ``DatabaseWrapper`` however preserves the previous behavior by disabling thread-sharing by default, so this does not affect any existing code that purely relies on the ORM or on ``DatabaseWrapper.cursor()``. -Finally, while it is now possible to pass connections between threads, Django -does not make any effort to synchronize access to the underlying backend. +Finally, while it's now possible to pass connections between threads, Django +doesn't make any effort to synchronize access to the underlying backend. Concurrency behavior is defined by the underlying backend implementation. Check their documentation for details. @@ -964,9 +964,9 @@ wild, because they would confuse browsers too. ``assertTemplateUsed`` and ``assertTemplateNotUsed`` as context manager ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It is now possible to check whether a template was used or not in a block of -code with the :meth:`~django.test.testcase.TestCase.assertTemplateUsed` and -:meth:`~django.test.testcase.TestCase.assertTemplateNotUsed` assertions. They +It's now possible to check whether a template was used within a block of +code with :meth:`~django.test.testcase.TestCase.assertTemplateUsed` and +:meth:`~django.test.testcase.TestCase.assertTemplateNotUsed`. And they can be used as a context manager:: with self.assertTemplateUsed('index.html'): @@ -974,18 +974,18 @@ can be used as a context manager:: with self.assertTemplateNotUsed('base.html'): render_to_string('index.html') -See the :ref:`assertion documentation` for more information. +See the :ref:`assertion documentation` for more. Database connections after running the test suite ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The default test runner now does not restore the database connections after the -tests' execution any more. This prevents the production database from being -exposed to potential threads that would still be running and attempting to -create new connections. +The default test runner no longer restores the database connections after +tests' execution. This prevents the production database from being exposed to +potential threads that would still be running and attempting to create new +connections. If your code relied on connections to the production database being created -after the tests' execution, then you may restore the previous behavior by +after tests' execution, then you can restore the previous behavior by subclassing ``DjangoTestRunner`` and overriding its ``teardown_databases()`` method. diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index cd1f43ae49..d2aa8863fc 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -622,11 +622,11 @@ Providing initial values .. versionadded:: 1.4 -As with regular formsets, it is possible to :ref:`specify initial data +As with regular formsets, it's possible to :ref:`specify initial data ` for forms in the formset by specifying an ``initial`` parameter when instantiating the model formset class returned by -``modelformset_factory``. However, with model formsets the initial values only -apply to extra forms, those which are not bound to an existing object instance. +``modelformset_factory``. However, with model formsets, the initial values only +apply to extra forms, those that aren't bound to an existing object instance. .. _saving-objects-in-the-formset: diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index ebc9f1ab28..f7c906b3e6 100644 --- a/docs/topics/testing.txt +++ b/docs/topics/testing.txt @@ -1593,11 +1593,10 @@ your test suite. .. versionadded:: 1.4 - You can also use this as a context manager. The code that is executed - under the with statement is then observed instead of a response:: + You can use this as a context manager, like this:: - # This is necessary in Python 2.5 to enable the with statement, in 2.6 - # and up it is no longer necessary. + # This is necessary in Python 2.5 to enable the with statement. + # In 2.6 and up, it's not necessary. from __future__ import with_statement with self.assertTemplateUsed('index.html'): @@ -1680,14 +1679,14 @@ your test suite. is based on HTML semantics. The comparison takes following things into account: - * Whitespace before and after HTML tags is ignored - * All types of whitespace are considered equivalent - * All open tags are closed implicitly, i.e. when a surrounding tag is - closed or the HTML document ends - * Empty tags are equivalent to their self-closing version - * The ordering of attributes of an HTML element is not significant + * Whitespace before and after HTML tags is ignored. + * All types of whitespace are considered equivalent. + * All open tags are closed implicitly, e.g. when a surrounding tag is + closed or the HTML document ends. + * Empty tags are equivalent to their self-closing version. + * The ordering of attributes of an HTML element is not significant. * Attributes without an argument are equal to attributes that equal in - name and value (see the examples) + name and value (see the examples). The following examples are valid tests and don't raise any ``AssertionError``:: @@ -1714,7 +1713,6 @@ your test suite. ``html1`` and ``html2`` must be valid HTML. An ``AssertionError`` will be raised if one of them cannot be parsed. - .. _topics-testing-email: Email services diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py index 19f35f9dbd..72a815423d 100644 --- a/tests/regressiontests/test_utils/tests.py +++ b/tests/regressiontests/test_utils/tests.py @@ -357,7 +357,7 @@ class HTMLEqualTests(TestCase):

This is a valid paragraph

this is a div AFTER the p
-

""")