File: test_settings.py

package info (click to toggle)
python-django 1.8.18-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 41,628 kB
  • sloc: python: 189,488; xml: 695; makefile: 194; sh: 169; sql: 11
file content (29 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys
import unittest

from django.test import TestCase


@unittest.skipIf(sys.version_info < (3, 3),
    'Python < 3.3 cannot import the project template because '
    'django/conf/project_template doesn\'t have an __init__.py file.')
class TestStartProjectSettings(TestCase):

    def test_middleware_classes_headers(self):
        """
        Ensure headers sent by the default MIDDLEWARE_CLASSES do not
        inadvertently change. For example, we never want "Vary: Cookie" to
        appear in the list since it prevents the caching of responses.
        """
        from django.conf.project_template.project_name.settings import MIDDLEWARE_CLASSES

        with self.settings(
            MIDDLEWARE_CLASSES=MIDDLEWARE_CLASSES,
            ROOT_URLCONF='project_template.urls',
        ):
            response = self.client.get('/empty/')
            headers = sorted(response.serialize_headers().split(b'\r\n'))
            self.assertEqual(headers, [
                b'Content-Type: text/html; charset=utf-8',
                b'X-Frame-Options: SAMEORIGIN',
            ])