commit
65c4ac3b24
|
@ -234,7 +234,7 @@ class Distance(MeasureBase):
|
||||||
'british_yd': 0.914398414616,
|
'british_yd': 0.914398414616,
|
||||||
'clarke_ft': 0.3047972654,
|
'clarke_ft': 0.3047972654,
|
||||||
'clarke_link': 0.201166195164,
|
'clarke_link': 0.201166195164,
|
||||||
'fathom': 1.8288,
|
'fathom': 1.8288,
|
||||||
'ft': 0.3048,
|
'ft': 0.3048,
|
||||||
'german_m': 1.0000135965,
|
'german_m': 1.0000135965,
|
||||||
'gold_coast_ft': 0.304799710181508,
|
'gold_coast_ft': 0.304799710181508,
|
||||||
|
|
|
@ -49,7 +49,7 @@ class GeoFeedTest(TestCase):
|
||||||
# Incrementing through the feeds.
|
# Incrementing through the feeds.
|
||||||
for feed in [feed1, feed2]:
|
for feed in [feed1, feed2]:
|
||||||
# Ensuring the georss namespace was added to the <rss> element.
|
# Ensuring the georss namespace was added to the <rss> element.
|
||||||
self.assertEqual(feed.getAttribute('xmlns:georss'), 'http://www.georss.org/georss')
|
self.assertEqual(feed.getAttribute('xmlns:georss'), 'http://www.georss.org/georss')
|
||||||
chan = feed.getElementsByTagName('channel')[0]
|
chan = feed.getElementsByTagName('channel')[0]
|
||||||
items = chan.getElementsByTagName('item')
|
items = chan.getElementsByTagName('item')
|
||||||
self.assertEqual(len(items), City.objects.count())
|
self.assertEqual(len(items), City.objects.count())
|
||||||
|
@ -69,7 +69,7 @@ class GeoFeedTest(TestCase):
|
||||||
|
|
||||||
for feed in [feed1, feed2]:
|
for feed in [feed1, feed2]:
|
||||||
# Ensuring the georsss namespace was added to the <feed> element.
|
# Ensuring the georsss namespace was added to the <feed> element.
|
||||||
self.assertEqual(feed.getAttribute('xmlns:georss'), 'http://www.georss.org/georss')
|
self.assertEqual(feed.getAttribute('xmlns:georss'), 'http://www.georss.org/georss')
|
||||||
entries = feed.getElementsByTagName('entry')
|
entries = feed.getElementsByTagName('entry')
|
||||||
self.assertEqual(len(entries), City.objects.count())
|
self.assertEqual(len(entries), City.objects.count())
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class RelatedGeoModelTest(TestCase):
|
||||||
cities = (
|
cities = (
|
||||||
('Aurora', 'TX', -97.516111, 33.058333),
|
('Aurora', 'TX', -97.516111, 33.058333),
|
||||||
('Roswell', 'NM', -104.528056, 33.387222),
|
('Roswell', 'NM', -104.528056, 33.387222),
|
||||||
('Kecksburg', 'PA', -79.460734, 40.18476),
|
('Kecksburg', 'PA', -79.460734, 40.18476),
|
||||||
)
|
)
|
||||||
|
|
||||||
for qs in (qs1, qs2, qs3):
|
for qs in (qs1, qs2, qs3):
|
||||||
|
|
|
@ -6,9 +6,11 @@ from django.utils.six.moves.urllib.request import urlopen
|
||||||
|
|
||||||
PING_URL = "http://www.google.com/webmasters/tools/ping"
|
PING_URL = "http://www.google.com/webmasters/tools/ping"
|
||||||
|
|
||||||
|
|
||||||
class SitemapNotFound(Exception):
|
class SitemapNotFound(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def ping_google(sitemap_url=None, ping_url=PING_URL):
|
def ping_google(sitemap_url=None, ping_url=PING_URL):
|
||||||
"""
|
"""
|
||||||
Alerts Google that the sitemap for the current site has been updated.
|
Alerts Google that the sitemap for the current site has been updated.
|
||||||
|
@ -35,6 +37,7 @@ def ping_google(sitemap_url=None, ping_url=PING_URL):
|
||||||
params = urlencode({'sitemap': url})
|
params = urlencode({'sitemap': url})
|
||||||
urlopen("%s?%s" % (ping_url, params))
|
urlopen("%s?%s" % (ping_url, params))
|
||||||
|
|
||||||
|
|
||||||
class Sitemap(object):
|
class Sitemap(object):
|
||||||
# This limit is defined by Google. See the index documentation at
|
# This limit is defined by Google. See the index documentation at
|
||||||
# http://sitemaps.org/protocol.php#index.
|
# http://sitemaps.org/protocol.php#index.
|
||||||
|
@ -94,22 +97,24 @@ class Sitemap(object):
|
||||||
(latest_lastmod is None or lastmod > latest_lastmod)):
|
(latest_lastmod is None or lastmod > latest_lastmod)):
|
||||||
latest_lastmod = lastmod
|
latest_lastmod = lastmod
|
||||||
url_info = {
|
url_info = {
|
||||||
'item': item,
|
'item': item,
|
||||||
'location': loc,
|
'location': loc,
|
||||||
'lastmod': lastmod,
|
'lastmod': lastmod,
|
||||||
'changefreq': self.__get('changefreq', item, None),
|
'changefreq': self.__get('changefreq', item, None),
|
||||||
'priority': str(priority if priority is not None else ''),
|
'priority': str(priority if priority is not None else ''),
|
||||||
}
|
}
|
||||||
urls.append(url_info)
|
urls.append(url_info)
|
||||||
if all_items_lastmod and latest_lastmod:
|
if all_items_lastmod and latest_lastmod:
|
||||||
self.latest_lastmod = latest_lastmod
|
self.latest_lastmod = latest_lastmod
|
||||||
return urls
|
return urls
|
||||||
|
|
||||||
|
|
||||||
class FlatPageSitemap(Sitemap):
|
class FlatPageSitemap(Sitemap):
|
||||||
def items(self):
|
def items(self):
|
||||||
current_site = Site.objects.get_current()
|
current_site = Site.objects.get_current()
|
||||||
return current_site.flatpage_set.filter(registration_required=False)
|
return current_site.flatpage_set.filter(registration_required=False)
|
||||||
|
|
||||||
|
|
||||||
class GenericSitemap(Sitemap):
|
class GenericSitemap(Sitemap):
|
||||||
priority = None
|
priority = None
|
||||||
changefreq = None
|
changefreq = None
|
||||||
|
|
|
@ -72,9 +72,9 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
self.serialization_formats = serializers.get_public_serializer_formats()
|
self.serialization_formats = serializers.get_public_serializer_formats()
|
||||||
self.compression_formats = {
|
self.compression_formats = {
|
||||||
None: open,
|
None: open,
|
||||||
'gz': gzip.GzipFile,
|
'gz': gzip.GzipFile,
|
||||||
'zip': SingleZipReader
|
'zip': SingleZipReader
|
||||||
}
|
}
|
||||||
if has_bz2:
|
if has_bz2:
|
||||||
self.compression_formats['bz2'] = bz2.BZ2File
|
self.compression_formats['bz2'] = bz2.BZ2File
|
||||||
|
|
|
@ -111,7 +111,7 @@ def get_validation_errors(outfile, app=None):
|
||||||
try:
|
try:
|
||||||
max_digits = int(f.max_digits)
|
max_digits = int(f.max_digits)
|
||||||
if max_digits <= 0:
|
if max_digits <= 0:
|
||||||
e.add(opts, mdigits_msg % f.name)
|
e.add(opts, mdigits_msg % f.name)
|
||||||
else:
|
else:
|
||||||
mdigits_ok = True
|
mdigits_ok = True
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
|
|
|
@ -19,6 +19,7 @@ __all__ = ('SelectDateWidget',)
|
||||||
|
|
||||||
RE_DATE = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$')
|
RE_DATE = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$')
|
||||||
|
|
||||||
|
|
||||||
def _parse_date_fmt():
|
def _parse_date_fmt():
|
||||||
fmt = get_format('DATE_FORMAT')
|
fmt = get_format('DATE_FORMAT')
|
||||||
escaped = False
|
escaped = False
|
||||||
|
@ -39,6 +40,7 @@ def _parse_date_fmt():
|
||||||
#if not self.first_select: self.first_select = 'day'
|
#if not self.first_select: self.first_select = 'day'
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
class SelectDateWidget(Widget):
|
class SelectDateWidget(Widget):
|
||||||
"""
|
"""
|
||||||
A Widget that splits date input into three <select> boxes.
|
A Widget that splits date input into three <select> boxes.
|
||||||
|
@ -90,7 +92,7 @@ class SelectDateWidget(Widget):
|
||||||
choices = list(six.iteritems(self.months))
|
choices = list(six.iteritems(self.months))
|
||||||
month_html = self.create_select(name, self.month_field, value, month_val, choices)
|
month_html = self.create_select(name, self.month_field, value, month_val, choices)
|
||||||
choices = [(i, i) for i in range(1, 32)]
|
choices = [(i, i) for i in range(1, 32)]
|
||||||
day_html = self.create_select(name, self.day_field, value, day_val, choices)
|
day_html = self.create_select(name, self.day_field, value, day_val, choices)
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
for field in _parse_date_fmt():
|
for field in _parse_date_fmt():
|
||||||
|
|
|
@ -222,21 +222,21 @@ class RequestFactory(object):
|
||||||
# - REMOTE_ADDR: often useful, see #8551.
|
# - REMOTE_ADDR: often useful, see #8551.
|
||||||
# See http://www.python.org/dev/peps/pep-3333/#environ-variables
|
# See http://www.python.org/dev/peps/pep-3333/#environ-variables
|
||||||
environ = {
|
environ = {
|
||||||
'HTTP_COOKIE': self.cookies.output(header='', sep='; '),
|
'HTTP_COOKIE': self.cookies.output(header='', sep='; '),
|
||||||
'PATH_INFO': str('/'),
|
'PATH_INFO': str('/'),
|
||||||
'REMOTE_ADDR': str('127.0.0.1'),
|
'REMOTE_ADDR': str('127.0.0.1'),
|
||||||
'REQUEST_METHOD': str('GET'),
|
'REQUEST_METHOD': str('GET'),
|
||||||
'SCRIPT_NAME': str(''),
|
'SCRIPT_NAME': str(''),
|
||||||
'SERVER_NAME': str('testserver'),
|
'SERVER_NAME': str('testserver'),
|
||||||
'SERVER_PORT': str('80'),
|
'SERVER_PORT': str('80'),
|
||||||
'SERVER_PROTOCOL': str('HTTP/1.1'),
|
'SERVER_PROTOCOL': str('HTTP/1.1'),
|
||||||
'wsgi.version': (1, 0),
|
'wsgi.version': (1, 0),
|
||||||
'wsgi.url_scheme': str('http'),
|
'wsgi.url_scheme': str('http'),
|
||||||
'wsgi.input': FakePayload(b''),
|
'wsgi.input': FakePayload(b''),
|
||||||
'wsgi.errors': self.errors,
|
'wsgi.errors': self.errors,
|
||||||
'wsgi.multiprocess': True,
|
'wsgi.multiprocess': True,
|
||||||
'wsgi.multithread': False,
|
'wsgi.multithread': False,
|
||||||
'wsgi.run_once': False,
|
'wsgi.run_once': False,
|
||||||
}
|
}
|
||||||
environ.update(self.defaults)
|
environ.update(self.defaults)
|
||||||
environ.update(request)
|
environ.update(request)
|
||||||
|
@ -327,7 +327,7 @@ class RequestFactory(object):
|
||||||
parsed = urlparse(path)
|
parsed = urlparse(path)
|
||||||
data = force_bytes(data, settings.DEFAULT_CHARSET)
|
data = force_bytes(data, settings.DEFAULT_CHARSET)
|
||||||
r = {
|
r = {
|
||||||
'PATH_INFO': self._get_path(parsed),
|
'PATH_INFO': self._get_path(parsed),
|
||||||
'REQUEST_METHOD': str(method),
|
'REQUEST_METHOD': str(method),
|
||||||
'SERVER_PORT': str('443') if secure else str('80'),
|
'SERVER_PORT': str('443') if secure else str('80'),
|
||||||
'wsgi.url_scheme': str('https') if secure else str('http'),
|
'wsgi.url_scheme': str('https') if secure else str('http'),
|
||||||
|
@ -335,8 +335,8 @@ class RequestFactory(object):
|
||||||
if data:
|
if data:
|
||||||
r.update({
|
r.update({
|
||||||
'CONTENT_LENGTH': len(data),
|
'CONTENT_LENGTH': len(data),
|
||||||
'CONTENT_TYPE': str(content_type),
|
'CONTENT_TYPE': str(content_type),
|
||||||
'wsgi.input': FakePayload(data),
|
'wsgi.input': FakePayload(data),
|
||||||
})
|
})
|
||||||
r.update(extra)
|
r.update(extra)
|
||||||
# If QUERY_STRING is absent or empty, we want to extract it from the URL.
|
# If QUERY_STRING is absent or empty, we want to extract it from the URL.
|
||||||
|
|
|
@ -23,7 +23,7 @@ from django.utils.translation import deactivate
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'Approximate', 'ContextList', 'get_runner', 'override_settings',
|
'Approximate', 'ContextList', 'get_runner', 'override_settings',
|
||||||
'requires_tz_support', 'setup_test_environment', 'teardown_test_environment',
|
'requires_tz_support', 'setup_test_environment', 'teardown_test_environment',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# Originally from https://bitbucket.org/ned/jslex
|
# Originally from https://bitbucket.org/ned/jslex
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
class Tok(object):
|
class Tok(object):
|
||||||
"""
|
"""
|
||||||
A specification for a token class.
|
A specification for a token class.
|
||||||
|
@ -15,6 +16,7 @@ class Tok(object):
|
||||||
self.regex = regex
|
self.regex = regex
|
||||||
self.next = next
|
self.next = next
|
||||||
|
|
||||||
|
|
||||||
def literals(choices, prefix="", suffix=""):
|
def literals(choices, prefix="", suffix=""):
|
||||||
"""
|
"""
|
||||||
Create a regex from a space-separated list of literal `choices`.
|
Create a regex from a space-separated list of literal `choices`.
|
||||||
|
@ -97,49 +99,49 @@ class JsLexer(Lexer):
|
||||||
# http://inimino.org/~inimino/blog/javascript_semicolons
|
# http://inimino.org/~inimino/blog/javascript_semicolons
|
||||||
|
|
||||||
both_before = [
|
both_before = [
|
||||||
Tok("comment", r"/\*(.|\n)*?\*/"),
|
Tok("comment", r"/\*(.|\n)*?\*/"),
|
||||||
Tok("linecomment", r"//.*?$"),
|
Tok("linecomment", r"//.*?$"),
|
||||||
Tok("ws", r"\s+"),
|
Tok("ws", r"\s+"),
|
||||||
Tok("keyword", literals("""
|
Tok("keyword", literals("""
|
||||||
break case catch class const continue debugger
|
break case catch class const continue debugger
|
||||||
default delete do else enum export extends
|
default delete do else enum export extends
|
||||||
finally for function if import in instanceof
|
finally for function if import in instanceof
|
||||||
new return super switch this throw try typeof
|
new return super switch this throw try typeof
|
||||||
var void while with
|
var void while with
|
||||||
""", suffix=r"\b"), next='reg'),
|
""", suffix=r"\b"), next='reg'),
|
||||||
Tok("reserved", literals("null true false", suffix=r"\b"), next='div'),
|
Tok("reserved", literals("null true false", suffix=r"\b"), next='div'),
|
||||||
Tok("id", r"""
|
Tok("id", r"""
|
||||||
([a-zA-Z_$ ]|\\u[0-9a-fA-Z]{4}) # first char
|
([a-zA-Z_$ ]|\\u[0-9a-fA-Z]{4}) # first char
|
||||||
([a-zA-Z_$0-9]|\\u[0-9a-fA-F]{4})* # rest chars
|
([a-zA-Z_$0-9]|\\u[0-9a-fA-F]{4})* # rest chars
|
||||||
""", next='div'),
|
""", next='div'),
|
||||||
Tok("hnum", r"0[xX][0-9a-fA-F]+", next='div'),
|
Tok("hnum", r"0[xX][0-9a-fA-F]+", next='div'),
|
||||||
Tok("onum", r"0[0-7]+"),
|
Tok("onum", r"0[0-7]+"),
|
||||||
Tok("dnum", r"""
|
Tok("dnum", r"""
|
||||||
( (0|[1-9][0-9]*) # DecimalIntegerLiteral
|
( (0|[1-9][0-9]*) # DecimalIntegerLiteral
|
||||||
\. # dot
|
\. # dot
|
||||||
[0-9]* # DecimalDigits-opt
|
[0-9]* # DecimalDigits-opt
|
||||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||||
|
|
|
|
||||||
\. # dot
|
\. # dot
|
||||||
[0-9]+ # DecimalDigits
|
[0-9]+ # DecimalDigits
|
||||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||||
|
|
|
|
||||||
(0|[1-9][0-9]*) # DecimalIntegerLiteral
|
(0|[1-9][0-9]*) # DecimalIntegerLiteral
|
||||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||||
)
|
)
|
||||||
""", next='div'),
|
""", next='div'),
|
||||||
Tok("punct", literals("""
|
Tok("punct", literals("""
|
||||||
>>>= === !== >>> <<= >>= <= >= == != << >> &&
|
>>>= === !== >>> <<= >>= <= >= == != << >> &&
|
||||||
|| += -= *= %= &= |= ^=
|
|| += -= *= %= &= |= ^=
|
||||||
"""), next="reg"),
|
"""), next="reg"),
|
||||||
Tok("punct", literals("++ -- ) ]"), next='div'),
|
Tok("punct", literals("++ -- ) ]"), next='div'),
|
||||||
Tok("punct", literals("{ } ( [ . ; , < > + - * % & | ^ ! ~ ? : ="), next='reg'),
|
Tok("punct", literals("{ } ( [ . ; , < > + - * % & | ^ ! ~ ? : ="), next='reg'),
|
||||||
Tok("string", r'"([^"\\]|(\\(.|\n)))*?"', next='div'),
|
Tok("string", r'"([^"\\]|(\\(.|\n)))*?"', next='div'),
|
||||||
Tok("string", r"'([^'\\]|(\\(.|\n)))*?'", next='div'),
|
Tok("string", r"'([^'\\]|(\\(.|\n)))*?'", next='div'),
|
||||||
]
|
]
|
||||||
|
|
||||||
both_after = [
|
both_after = [
|
||||||
Tok("other", r"."),
|
Tok("other", r"."),
|
||||||
]
|
]
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
|
|
|
@ -11,6 +11,7 @@ background = dict((color_names[x], '4%s' % x) for x in range(8))
|
||||||
RESET = '0'
|
RESET = '0'
|
||||||
opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
|
opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
|
||||||
|
|
||||||
|
|
||||||
def colorize(text='', opts=(), **kwargs):
|
def colorize(text='', opts=(), **kwargs):
|
||||||
"""
|
"""
|
||||||
Returns your text, enclosed in ANSI graphics codes.
|
Returns your text, enclosed in ANSI graphics codes.
|
||||||
|
@ -55,6 +56,7 @@ def colorize(text='', opts=(), **kwargs):
|
||||||
text = '%s\x1b[%sm' % (text or '', RESET)
|
text = '%s\x1b[%sm' % (text or '', RESET)
|
||||||
return '%s%s' % (('\x1b[%sm' % ';'.join(code_list)), text or '')
|
return '%s%s' % (('\x1b[%sm' % ';'.join(code_list)), text or '')
|
||||||
|
|
||||||
|
|
||||||
def make_style(opts=(), **kwargs):
|
def make_style(opts=(), **kwargs):
|
||||||
"""
|
"""
|
||||||
Returns a function with default parameters for colorize()
|
Returns a function with default parameters for colorize()
|
||||||
|
@ -73,65 +75,66 @@ LIGHT_PALETTE = 'light'
|
||||||
|
|
||||||
PALETTES = {
|
PALETTES = {
|
||||||
NOCOLOR_PALETTE: {
|
NOCOLOR_PALETTE: {
|
||||||
'ERROR': {},
|
'ERROR': {},
|
||||||
'NOTICE': {},
|
'NOTICE': {},
|
||||||
'SQL_FIELD': {},
|
'SQL_FIELD': {},
|
||||||
'SQL_COLTYPE': {},
|
'SQL_COLTYPE': {},
|
||||||
'SQL_KEYWORD': {},
|
'SQL_KEYWORD': {},
|
||||||
'SQL_TABLE': {},
|
'SQL_TABLE': {},
|
||||||
'HTTP_INFO': {},
|
'HTTP_INFO': {},
|
||||||
'HTTP_SUCCESS': {},
|
'HTTP_SUCCESS': {},
|
||||||
'HTTP_REDIRECT': {},
|
'HTTP_REDIRECT': {},
|
||||||
'HTTP_NOT_MODIFIED': {},
|
'HTTP_NOT_MODIFIED': {},
|
||||||
'HTTP_BAD_REQUEST': {},
|
'HTTP_BAD_REQUEST': {},
|
||||||
'HTTP_NOT_FOUND': {},
|
'HTTP_NOT_FOUND': {},
|
||||||
'HTTP_SERVER_ERROR': {},
|
'HTTP_SERVER_ERROR': {},
|
||||||
'MIGRATE_HEADING': {},
|
'MIGRATE_HEADING': {},
|
||||||
'MIGRATE_LABEL': {},
|
'MIGRATE_LABEL': {},
|
||||||
'MIGRATE_SUCCESS': {},
|
'MIGRATE_SUCCESS': {},
|
||||||
'MIGRATE_FAILURE': {},
|
'MIGRATE_FAILURE': {},
|
||||||
},
|
},
|
||||||
DARK_PALETTE: {
|
DARK_PALETTE: {
|
||||||
'ERROR': {'fg': 'red', 'opts': ('bold',)},
|
'ERROR': {'fg': 'red', 'opts': ('bold',)},
|
||||||
'NOTICE': {'fg': 'red'},
|
'NOTICE': {'fg': 'red'},
|
||||||
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
|
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
|
||||||
'SQL_COLTYPE': {'fg': 'green'},
|
'SQL_COLTYPE': {'fg': 'green'},
|
||||||
'SQL_KEYWORD': {'fg': 'yellow'},
|
'SQL_KEYWORD': {'fg': 'yellow'},
|
||||||
'SQL_TABLE': {'opts': ('bold',)},
|
'SQL_TABLE': {'opts': ('bold',)},
|
||||||
'HTTP_INFO': {'opts': ('bold',)},
|
'HTTP_INFO': {'opts': ('bold',)},
|
||||||
'HTTP_SUCCESS': {},
|
'HTTP_SUCCESS': {},
|
||||||
'HTTP_REDIRECT': {'fg': 'green'},
|
'HTTP_REDIRECT': {'fg': 'green'},
|
||||||
'HTTP_NOT_MODIFIED': {'fg': 'cyan'},
|
'HTTP_NOT_MODIFIED': {'fg': 'cyan'},
|
||||||
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
|
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
|
||||||
'HTTP_NOT_FOUND': {'fg': 'yellow'},
|
'HTTP_NOT_FOUND': {'fg': 'yellow'},
|
||||||
'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)},
|
'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)},
|
||||||
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
|
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
|
||||||
'MIGRATE_LABEL': {'opts': ('bold',)},
|
'MIGRATE_LABEL': {'opts': ('bold',)},
|
||||||
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
|
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
|
||||||
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
|
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
|
||||||
},
|
},
|
||||||
LIGHT_PALETTE: {
|
LIGHT_PALETTE: {
|
||||||
'ERROR': {'fg': 'red', 'opts': ('bold',)},
|
'ERROR': {'fg': 'red', 'opts': ('bold',)},
|
||||||
'NOTICE': {'fg': 'red'},
|
'NOTICE': {'fg': 'red'},
|
||||||
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
|
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
|
||||||
'SQL_COLTYPE': {'fg': 'green'},
|
'SQL_COLTYPE': {'fg': 'green'},
|
||||||
'SQL_KEYWORD': {'fg': 'blue'},
|
'SQL_KEYWORD': {'fg': 'blue'},
|
||||||
'SQL_TABLE': {'opts': ('bold',)},
|
'SQL_TABLE': {'opts': ('bold',)},
|
||||||
'HTTP_INFO': {'opts': ('bold',)},
|
'HTTP_INFO': {'opts': ('bold',)},
|
||||||
'HTTP_SUCCESS': {},
|
'HTTP_SUCCESS': {},
|
||||||
'HTTP_REDIRECT': {'fg': 'green', 'opts': ('bold',)},
|
'HTTP_REDIRECT': {'fg': 'green', 'opts': ('bold',)},
|
||||||
'HTTP_NOT_MODIFIED': {'fg': 'green'},
|
'HTTP_NOT_MODIFIED': {'fg': 'green'},
|
||||||
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
|
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
|
||||||
'HTTP_NOT_FOUND': {'fg': 'red'},
|
'HTTP_NOT_FOUND': {'fg': 'red'},
|
||||||
'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)},
|
'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)},
|
||||||
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
|
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
|
||||||
'MIGRATE_LABEL': {'opts': ('bold',)},
|
'MIGRATE_LABEL': {'opts': ('bold',)},
|
||||||
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
|
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
|
||||||
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
|
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEFAULT_PALETTE = DARK_PALETTE
|
DEFAULT_PALETTE = DARK_PALETTE
|
||||||
|
|
||||||
|
|
||||||
def parse_color_setting(config_string):
|
def parse_color_setting(config_string):
|
||||||
"""Parse a DJANGO_COLORS environment variable to produce the system palette
|
"""Parse a DJANGO_COLORS environment variable to produce the system palette
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from django.utils import six
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'activate', 'deactivate', 'override', 'deactivate_all',
|
'activate', 'deactivate', 'override', 'deactivate_all',
|
||||||
'get_language', 'get_language_from_request',
|
'get_language', 'get_language_from_request',
|
||||||
'get_language_info', 'get_language_bidi',
|
'get_language_info', 'get_language_bidi',
|
||||||
'check_for_language', 'to_locale', 'templatize', 'string_concat',
|
'check_for_language', 'to_locale', 'templatize', 'string_concat',
|
||||||
'gettext', 'gettext_lazy', 'gettext_noop',
|
'gettext', 'gettext_lazy', 'gettext_noop',
|
||||||
|
|
|
@ -19,38 +19,39 @@ from sphinx.util.nodes import set_source_info
|
||||||
simple_option_desc_re = re.compile(
|
simple_option_desc_re = re.compile(
|
||||||
r'([-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)')
|
r'([-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)')
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_crossref_type(
|
app.add_crossref_type(
|
||||||
directivename = "setting",
|
directivename="setting",
|
||||||
rolename = "setting",
|
rolename="setting",
|
||||||
indextemplate = "pair: %s; setting",
|
indextemplate="pair: %s; setting",
|
||||||
)
|
)
|
||||||
app.add_crossref_type(
|
app.add_crossref_type(
|
||||||
directivename = "templatetag",
|
directivename="templatetag",
|
||||||
rolename = "ttag",
|
rolename="ttag",
|
||||||
indextemplate = "pair: %s; template tag"
|
indextemplate="pair: %s; template tag"
|
||||||
)
|
)
|
||||||
app.add_crossref_type(
|
app.add_crossref_type(
|
||||||
directivename = "templatefilter",
|
directivename="templatefilter",
|
||||||
rolename = "tfilter",
|
rolename="tfilter",
|
||||||
indextemplate = "pair: %s; template filter"
|
indextemplate="pair: %s; template filter"
|
||||||
)
|
)
|
||||||
app.add_crossref_type(
|
app.add_crossref_type(
|
||||||
directivename = "fieldlookup",
|
directivename="fieldlookup",
|
||||||
rolename = "lookup",
|
rolename="lookup",
|
||||||
indextemplate = "pair: %s; field lookup type",
|
indextemplate="pair: %s; field lookup type",
|
||||||
)
|
)
|
||||||
app.add_description_unit(
|
app.add_description_unit(
|
||||||
directivename = "django-admin",
|
directivename="django-admin",
|
||||||
rolename = "djadmin",
|
rolename="djadmin",
|
||||||
indextemplate = "pair: %s; django-admin command",
|
indextemplate="pair: %s; django-admin command",
|
||||||
parse_node = parse_django_admin_node,
|
parse_node=parse_django_admin_node,
|
||||||
)
|
)
|
||||||
app.add_description_unit(
|
app.add_description_unit(
|
||||||
directivename = "django-admin-option",
|
directivename="django-admin-option",
|
||||||
rolename = "djadminopt",
|
rolename="djadminopt",
|
||||||
indextemplate = "pair: %s; django-admin command-line option",
|
indextemplate="pair: %s; django-admin command-line option",
|
||||||
parse_node = parse_django_adminopt_node,
|
parse_node=parse_django_adminopt_node,
|
||||||
)
|
)
|
||||||
app.add_config_value('django_next_version', '0.0', True)
|
app.add_config_value('django_next_version', '0.0', True)
|
||||||
app.add_directive('versionadded', VersionDirective)
|
app.add_directive('versionadded', VersionDirective)
|
||||||
|
@ -228,7 +229,7 @@ class DjangoHTMLTranslator(SmartyPantsHTMLTranslator):
|
||||||
def visit_table(self, node):
|
def visit_table(self, node):
|
||||||
self.context.append(self.compact_p)
|
self.context.append(self.compact_p)
|
||||||
self.compact_p = True
|
self.compact_p = True
|
||||||
self._table_row_index = 0 # Needed by Sphinx
|
self._table_row_index = 0 # Needed by Sphinx
|
||||||
self.body.append(self.starttag(node, 'table', CLASS='docutils'))
|
self.body.append(self.starttag(node, 'table', CLASS='docutils'))
|
||||||
|
|
||||||
def depart_table(self, node):
|
def depart_table(self, node):
|
||||||
|
@ -266,9 +267,9 @@ class DjangoHTMLTranslator(SmartyPantsHTMLTranslator):
|
||||||
# that work.
|
# that work.
|
||||||
#
|
#
|
||||||
version_text = {
|
version_text = {
|
||||||
'deprecated': 'Deprecated in Django %s',
|
'deprecated': 'Deprecated in Django %s',
|
||||||
'versionchanged': 'Changed in Django %s',
|
'versionchanged': 'Changed in Django %s',
|
||||||
'versionadded': 'New in Django %s',
|
'versionadded': 'New in Django %s',
|
||||||
}
|
}
|
||||||
|
|
||||||
def visit_versionmodified(self, node):
|
def visit_versionmodified(self, node):
|
||||||
|
|
|
@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/*
|
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/*
|
||||||
ignore=E124,E125,E127,E128,E226,E241,E251,E302,E501,E261,W601
|
ignore=E124,E125,E127,E128,E226,E251,E302,E501,E261,W601
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
license-file = LICENSE
|
license-file = LICENSE
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ExtraRegressTests(TestCase):
|
||||||
# select portions. Applies when portions are updated or otherwise
|
# select portions. Applies when portions are updated or otherwise
|
||||||
# moved around.
|
# moved around.
|
||||||
qs = User.objects.extra(
|
qs = User.objects.extra(
|
||||||
select=OrderedDict((("alpha", "%s"), ("beta", "2"), ("gamma", "%s"))),
|
select=OrderedDict((("alpha", "%s"), ("beta", "2"), ("gamma", "%s"))),
|
||||||
select_params=(1, 3)
|
select_params=(1, 3)
|
||||||
)
|
)
|
||||||
qs = qs.extra(select={"beta": 4})
|
qs = qs.extra(select={"beta": 4})
|
||||||
|
|
|
@ -26,6 +26,7 @@ UNICODE_FILENAME = 'test-0123456789_中文_Orléans.jpg'
|
||||||
MEDIA_ROOT = sys_tempfile.mkdtemp()
|
MEDIA_ROOT = sys_tempfile.mkdtemp()
|
||||||
UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload')
|
UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload')
|
||||||
|
|
||||||
|
|
||||||
@override_settings(MEDIA_ROOT=MEDIA_ROOT)
|
@override_settings(MEDIA_ROOT=MEDIA_ROOT)
|
||||||
class FileUploadTests(TestCase):
|
class FileUploadTests(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -85,10 +86,10 @@ class FileUploadTests(TestCase):
|
||||||
payload.write('--' + client.BOUNDARY + '--\r\n')
|
payload.write('--' + client.BOUNDARY + '--\r\n')
|
||||||
r = {
|
r = {
|
||||||
'CONTENT_LENGTH': len(payload),
|
'CONTENT_LENGTH': len(payload),
|
||||||
'CONTENT_TYPE': client.MULTIPART_CONTENT,
|
'CONTENT_TYPE': client.MULTIPART_CONTENT,
|
||||||
'PATH_INFO': "/file_uploads/echo_content/",
|
'PATH_INFO': "/file_uploads/echo_content/",
|
||||||
'REQUEST_METHOD': 'POST',
|
'REQUEST_METHOD': 'POST',
|
||||||
'wsgi.input': payload,
|
'wsgi.input': payload,
|
||||||
}
|
}
|
||||||
response = self.client.request(**r)
|
response = self.client.request(**r)
|
||||||
received = json.loads(response.content.decode('utf-8'))
|
received = json.loads(response.content.decode('utf-8'))
|
||||||
|
@ -152,10 +153,10 @@ class FileUploadTests(TestCase):
|
||||||
|
|
||||||
r = {
|
r = {
|
||||||
'CONTENT_LENGTH': len(payload),
|
'CONTENT_LENGTH': len(payload),
|
||||||
'CONTENT_TYPE': client.MULTIPART_CONTENT,
|
'CONTENT_TYPE': client.MULTIPART_CONTENT,
|
||||||
'PATH_INFO': "/file_uploads/echo/",
|
'PATH_INFO': "/file_uploads/echo/",
|
||||||
'REQUEST_METHOD': 'POST',
|
'REQUEST_METHOD': 'POST',
|
||||||
'wsgi.input': payload,
|
'wsgi.input': payload,
|
||||||
}
|
}
|
||||||
response = self.client.request(**r)
|
response = self.client.request(**r)
|
||||||
|
|
||||||
|
@ -189,10 +190,10 @@ class FileUploadTests(TestCase):
|
||||||
payload.write('\r\n--' + client.BOUNDARY + '--\r\n')
|
payload.write('\r\n--' + client.BOUNDARY + '--\r\n')
|
||||||
r = {
|
r = {
|
||||||
'CONTENT_LENGTH': len(payload),
|
'CONTENT_LENGTH': len(payload),
|
||||||
'CONTENT_TYPE': client.MULTIPART_CONTENT,
|
'CONTENT_TYPE': client.MULTIPART_CONTENT,
|
||||||
'PATH_INFO': "/file_uploads/echo/",
|
'PATH_INFO': "/file_uploads/echo/",
|
||||||
'REQUEST_METHOD': 'POST',
|
'REQUEST_METHOD': 'POST',
|
||||||
'wsgi.input': payload,
|
'wsgi.input': payload,
|
||||||
}
|
}
|
||||||
result = json.loads(self.client.request(**r).content.decode('utf-8'))
|
result = json.loads(self.client.request(**r).content.decode('utf-8'))
|
||||||
for name, _, expected in cases:
|
for name, _, expected in cases:
|
||||||
|
@ -444,6 +445,6 @@ class MultiParserTests(unittest.TestCase):
|
||||||
# We're not actually parsing here; just checking if the parser properly
|
# We're not actually parsing here; just checking if the parser properly
|
||||||
# instantiates with empty upload handlers.
|
# instantiates with empty upload handlers.
|
||||||
MultiPartParser({
|
MultiPartParser({
|
||||||
'CONTENT_TYPE': 'multipart/form-data; boundary=_foo',
|
'CONTENT_TYPE': 'multipart/form-data; boundary=_foo',
|
||||||
'CONTENT_LENGTH': '1'
|
'CONTENT_LENGTH': '1'
|
||||||
}, StringIO('x'), [], 'utf-8')
|
}, StringIO('x'), [], 'utf-8')
|
||||||
|
|
|
@ -4,15 +4,15 @@ from . import views
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'^upload/$', views.file_upload_view),
|
(r'^upload/$', views.file_upload_view),
|
||||||
(r'^verify/$', views.file_upload_view_verify),
|
(r'^verify/$', views.file_upload_view_verify),
|
||||||
(r'^unicode_name/$', views.file_upload_unicode_name),
|
(r'^unicode_name/$', views.file_upload_unicode_name),
|
||||||
(r'^echo/$', views.file_upload_echo),
|
(r'^echo/$', views.file_upload_echo),
|
||||||
(r'^echo_content_type_extra/$', views.file_upload_content_type_extra),
|
(r'^echo_content_type_extra/$', views.file_upload_content_type_extra),
|
||||||
(r'^echo_content/$', views.file_upload_echo_content),
|
(r'^echo_content/$', views.file_upload_echo_content),
|
||||||
(r'^quota/$', views.file_upload_quota),
|
(r'^quota/$', views.file_upload_quota),
|
||||||
(r'^quota/broken/$', views.file_upload_quota_broken),
|
(r'^quota/broken/$', views.file_upload_quota_broken),
|
||||||
(r'^getlist_count/$', views.file_upload_getlist_count),
|
(r'^getlist_count/$', views.file_upload_getlist_count),
|
||||||
(r'^upload_errors/$', views.file_upload_errors),
|
(r'^upload_errors/$', views.file_upload_errors),
|
||||||
(r'^filename_case/$', views.file_upload_filename_case_view),
|
(r'^filename_case/$', views.file_upload_filename_case_view),
|
||||||
)
|
)
|
||||||
|
|
|
@ -260,5 +260,5 @@ urlpatterns = patterns('',
|
||||||
views.BookSigningDetail.as_view()),
|
views.BookSigningDetail.as_view()),
|
||||||
|
|
||||||
# Useful for testing redirects
|
# Useful for testing redirects
|
||||||
(r'^accounts/login/$', 'django.contrib.auth.views.login')
|
(r'^accounts/login/$', 'django.contrib.auth.views.login')
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,7 +43,7 @@ class DictList(generic.ListView):
|
||||||
"""A ListView that doesn't use a model."""
|
"""A ListView that doesn't use a model."""
|
||||||
queryset = [
|
queryset = [
|
||||||
{'first': 'John', 'last': 'Lennon'},
|
{'first': 'John', 'last': 'Lennon'},
|
||||||
{'first': 'Yoko', 'last': 'Ono'}
|
{'first': 'Yoko', 'last': 'Ono'}
|
||||||
]
|
]
|
||||||
template_name = 'generic_views/list.html'
|
template_name = 'generic_views/list.html'
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ from django.utils.safestring import mark_safe, SafeBytes, SafeString, SafeText
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.six import PY3
|
from django.utils.six import PY3
|
||||||
from django.utils.translation import (activate, deactivate,
|
from django.utils.translation import (activate, deactivate,
|
||||||
get_language, get_language_from_request, get_language_info,
|
get_language, get_language_from_request, get_language_info,
|
||||||
to_locale, trans_real,
|
to_locale, trans_real,
|
||||||
gettext_lazy,
|
gettext_lazy,
|
||||||
ugettext, ugettext_lazy,
|
ugettext, ugettext_lazy,
|
||||||
|
|
|
@ -8,11 +8,12 @@ from django.template import Template
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
|
|
||||||
|
|
||||||
class TestException(Exception):
|
class TestException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# A middleware base class that tracks which methods have been called
|
|
||||||
|
|
||||||
|
# A middleware base class that tracks which methods have been called
|
||||||
class TestMiddleware(object):
|
class TestMiddleware(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.process_request_called = False
|
self.process_request_called = False
|
||||||
|
@ -38,28 +39,32 @@ class TestMiddleware(object):
|
||||||
def process_exception(self, request, exception):
|
def process_exception(self, request, exception):
|
||||||
self.process_exception_called = True
|
self.process_exception_called = True
|
||||||
|
|
||||||
# Middleware examples that do the right thing
|
|
||||||
|
|
||||||
|
# Middleware examples that do the right thing
|
||||||
class RequestMiddleware(TestMiddleware):
|
class RequestMiddleware(TestMiddleware):
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
super(RequestMiddleware, self).process_request(request)
|
super(RequestMiddleware, self).process_request(request)
|
||||||
return HttpResponse('Request Middleware')
|
return HttpResponse('Request Middleware')
|
||||||
|
|
||||||
|
|
||||||
class ViewMiddleware(TestMiddleware):
|
class ViewMiddleware(TestMiddleware):
|
||||||
def process_view(self, request, view_func, view_args, view_kwargs):
|
def process_view(self, request, view_func, view_args, view_kwargs):
|
||||||
super(ViewMiddleware, self).process_view(request, view_func, view_args, view_kwargs)
|
super(ViewMiddleware, self).process_view(request, view_func, view_args, view_kwargs)
|
||||||
return HttpResponse('View Middleware')
|
return HttpResponse('View Middleware')
|
||||||
|
|
||||||
|
|
||||||
class ResponseMiddleware(TestMiddleware):
|
class ResponseMiddleware(TestMiddleware):
|
||||||
def process_response(self, request, response):
|
def process_response(self, request, response):
|
||||||
super(ResponseMiddleware, self).process_response(request, response)
|
super(ResponseMiddleware, self).process_response(request, response)
|
||||||
return HttpResponse('Response Middleware')
|
return HttpResponse('Response Middleware')
|
||||||
|
|
||||||
|
|
||||||
class TemplateResponseMiddleware(TestMiddleware):
|
class TemplateResponseMiddleware(TestMiddleware):
|
||||||
def process_template_response(self, request, response):
|
def process_template_response(self, request, response):
|
||||||
super(TemplateResponseMiddleware, self).process_template_response(request, response)
|
super(TemplateResponseMiddleware, self).process_template_response(request, response)
|
||||||
return TemplateResponse(request, Template('Template Response Middleware'))
|
return TemplateResponse(request, Template('Template Response Middleware'))
|
||||||
|
|
||||||
|
|
||||||
class ExceptionMiddleware(TestMiddleware):
|
class ExceptionMiddleware(TestMiddleware):
|
||||||
def process_exception(self, request, exception):
|
def process_exception(self, request, exception):
|
||||||
super(ExceptionMiddleware, self).process_exception(request, exception)
|
super(ExceptionMiddleware, self).process_exception(request, exception)
|
||||||
|
@ -67,27 +72,30 @@ class ExceptionMiddleware(TestMiddleware):
|
||||||
|
|
||||||
|
|
||||||
# Sample middlewares that raise exceptions
|
# Sample middlewares that raise exceptions
|
||||||
|
|
||||||
class BadRequestMiddleware(TestMiddleware):
|
class BadRequestMiddleware(TestMiddleware):
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
super(BadRequestMiddleware, self).process_request(request)
|
super(BadRequestMiddleware, self).process_request(request)
|
||||||
raise TestException('Test Request Exception')
|
raise TestException('Test Request Exception')
|
||||||
|
|
||||||
|
|
||||||
class BadViewMiddleware(TestMiddleware):
|
class BadViewMiddleware(TestMiddleware):
|
||||||
def process_view(self, request, view_func, view_args, view_kwargs):
|
def process_view(self, request, view_func, view_args, view_kwargs):
|
||||||
super(BadViewMiddleware, self).process_view(request, view_func, view_args, view_kwargs)
|
super(BadViewMiddleware, self).process_view(request, view_func, view_args, view_kwargs)
|
||||||
raise TestException('Test View Exception')
|
raise TestException('Test View Exception')
|
||||||
|
|
||||||
|
|
||||||
class BadTemplateResponseMiddleware(TestMiddleware):
|
class BadTemplateResponseMiddleware(TestMiddleware):
|
||||||
def process_template_response(self, request, response):
|
def process_template_response(self, request, response):
|
||||||
super(BadTemplateResponseMiddleware, self).process_template_response(request, response)
|
super(BadTemplateResponseMiddleware, self).process_template_response(request, response)
|
||||||
raise TestException('Test Template Response Exception')
|
raise TestException('Test Template Response Exception')
|
||||||
|
|
||||||
|
|
||||||
class BadResponseMiddleware(TestMiddleware):
|
class BadResponseMiddleware(TestMiddleware):
|
||||||
def process_response(self, request, response):
|
def process_response(self, request, response):
|
||||||
super(BadResponseMiddleware, self).process_response(request, response)
|
super(BadResponseMiddleware, self).process_response(request, response)
|
||||||
raise TestException('Test Response Exception')
|
raise TestException('Test Response Exception')
|
||||||
|
|
||||||
|
|
||||||
class BadExceptionMiddleware(TestMiddleware):
|
class BadExceptionMiddleware(TestMiddleware):
|
||||||
def process_exception(self, request, exception):
|
def process_exception(self, request, exception):
|
||||||
super(BadExceptionMiddleware, self).process_exception(request, exception)
|
super(BadExceptionMiddleware, self).process_exception(request, exception)
|
||||||
|
@ -153,8 +161,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_middleware(self):
|
def test_process_view_middleware(self):
|
||||||
|
@ -167,8 +175,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_response_middleware(self):
|
def test_process_response_middleware(self):
|
||||||
|
@ -181,8 +189,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||||
|
|
||||||
def test_process_template_response_middleware(self):
|
def test_process_template_response_middleware(self):
|
||||||
|
@ -195,8 +203,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/template_response/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/template_response/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, True, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, True, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, True, True, False)
|
self.assert_middleware_usage(middleware, True, True, True, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, True, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, True, True, False)
|
||||||
|
|
||||||
def test_process_exception_middleware(self):
|
def test_process_exception_middleware(self):
|
||||||
|
@ -209,8 +217,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||||
|
|
||||||
def test_process_request_middleware_not_found(self):
|
def test_process_request_middleware_not_found(self):
|
||||||
|
@ -223,8 +231,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_middleware_not_found(self):
|
def test_process_view_middleware_not_found(self):
|
||||||
|
@ -237,8 +245,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_template_response_middleware_not_found(self):
|
def test_process_template_response_middleware_not_found(self):
|
||||||
|
@ -251,8 +259,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_response_middleware_not_found(self):
|
def test_process_response_middleware_not_found(self):
|
||||||
|
@ -265,8 +273,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_exception_middleware_not_found(self):
|
def test_process_exception_middleware_not_found(self):
|
||||||
|
@ -279,8 +287,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_request_middleware_exception(self):
|
def test_process_request_middleware_exception(self):
|
||||||
|
@ -293,8 +301,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_middleware_exception(self):
|
def test_process_view_middleware_exception(self):
|
||||||
|
@ -307,8 +315,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_response_middleware_exception(self):
|
def test_process_response_middleware_exception(self):
|
||||||
|
@ -321,8 +329,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Error in view'], Exception())
|
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Error in view'], Exception())
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_exception_middleware_exception(self):
|
def test_process_exception_middleware_exception(self):
|
||||||
|
@ -335,8 +343,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/error/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_request_middleware_null_view(self):
|
def test_process_request_middleware_null_view(self):
|
||||||
|
@ -349,8 +357,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/null_view/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/null_view/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_middleware_null_view(self):
|
def test_process_view_middleware_null_view(self):
|
||||||
|
@ -363,8 +371,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/null_view/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/null_view/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_response_middleware_null_view(self):
|
def test_process_response_middleware_null_view(self):
|
||||||
|
@ -380,8 +388,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
ValueError())
|
ValueError())
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||||
|
|
||||||
def test_process_exception_middleware_null_view(self):
|
def test_process_exception_middleware_null_view(self):
|
||||||
|
@ -397,8 +405,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
ValueError())
|
ValueError())
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||||
|
|
||||||
def test_process_request_middleware_permission_denied(self):
|
def test_process_request_middleware_permission_denied(self):
|
||||||
|
@ -411,8 +419,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
self.assert_middleware_usage(middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_middleware_permission_denied(self):
|
def test_process_view_middleware_permission_denied(self):
|
||||||
|
@ -425,8 +433,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
self.assert_middleware_usage(middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_response_middleware_permission_denied(self):
|
def test_process_response_middleware_permission_denied(self):
|
||||||
|
@ -439,8 +447,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_exception_middleware_permission_denied(self):
|
def test_process_exception_middleware_permission_denied(self):
|
||||||
|
@ -453,8 +461,8 @@ class MiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
self.assert_middleware_usage(middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_template_response_error(self):
|
def test_process_template_response_error(self):
|
||||||
|
@ -478,8 +486,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test Request Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test Request Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_bad_middleware(self):
|
def test_process_view_bad_middleware(self):
|
||||||
|
@ -492,8 +500,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test View Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test View Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_template_response_bad_middleware(self):
|
def test_process_template_response_bad_middleware(self):
|
||||||
|
@ -506,9 +514,9 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/template_response/', ['Test Template Response Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/template_response/', ['Test Template Response Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, True, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, True, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, True, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, True, True, False)
|
||||||
|
|
||||||
def test_process_response_bad_middleware(self):
|
def test_process_response_bad_middleware(self):
|
||||||
pre_middleware = TestMiddleware()
|
pre_middleware = TestMiddleware()
|
||||||
|
@ -520,9 +528,9 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test Response Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/view/', ['Test Response Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, False, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||||
|
|
||||||
def test_process_exception_bad_middleware(self):
|
def test_process_exception_bad_middleware(self):
|
||||||
pre_middleware = TestMiddleware()
|
pre_middleware = TestMiddleware()
|
||||||
|
@ -534,8 +542,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
self.assert_exceptions_handled('/middleware_exceptions/view/', [])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||||
|
|
||||||
def test_process_request_bad_middleware_not_found(self):
|
def test_process_request_bad_middleware_not_found(self):
|
||||||
|
@ -548,8 +556,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Request Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Request Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_bad_middleware_not_found(self):
|
def test_process_view_bad_middleware_not_found(self):
|
||||||
|
@ -562,8 +570,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test View Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test View Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_response_bad_middleware_not_found(self):
|
def test_process_response_bad_middleware_not_found(self):
|
||||||
|
@ -576,9 +584,9 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Response Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Response Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_exception_bad_middleware_not_found(self):
|
def test_process_exception_bad_middleware_not_found(self):
|
||||||
pre_middleware = TestMiddleware()
|
pre_middleware = TestMiddleware()
|
||||||
|
@ -590,8 +598,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Exception Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/not_found/', ['Test Exception Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_request_bad_middleware_exception(self):
|
def test_process_request_bad_middleware_exception(self):
|
||||||
|
@ -604,8 +612,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test Request Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test Request Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_bad_middleware_exception(self):
|
def test_process_view_bad_middleware_exception(self):
|
||||||
|
@ -618,8 +626,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test View Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test View Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_response_bad_middleware_exception(self):
|
def test_process_response_bad_middleware_exception(self):
|
||||||
|
@ -632,9 +640,9 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Error in view', 'Test Response Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Error in view', 'Test Response Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_exception_bad_middleware_exception(self):
|
def test_process_exception_bad_middleware_exception(self):
|
||||||
pre_middleware = TestMiddleware()
|
pre_middleware = TestMiddleware()
|
||||||
|
@ -646,8 +654,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test Exception Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/error/', ['Test Exception Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_request_bad_middleware_null_view(self):
|
def test_process_request_bad_middleware_null_view(self):
|
||||||
|
@ -660,8 +668,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/null_view/', ['Test Request Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/null_view/', ['Test Request Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_bad_middleware_null_view(self):
|
def test_process_view_bad_middleware_null_view(self):
|
||||||
|
@ -674,8 +682,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/null_view/', ['Test View Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/null_view/', ['Test View Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_response_bad_middleware_null_view(self):
|
def test_process_response_bad_middleware_null_view(self):
|
||||||
|
@ -691,9 +699,9 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
])
|
])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, False, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||||
|
|
||||||
def test_process_exception_bad_middleware_null_view(self):
|
def test_process_exception_bad_middleware_null_view(self):
|
||||||
pre_middleware = TestMiddleware()
|
pre_middleware = TestMiddleware()
|
||||||
|
@ -708,8 +716,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
ValueError())
|
ValueError())
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, False)
|
||||||
|
|
||||||
def test_process_request_bad_middleware_permission_denied(self):
|
def test_process_request_bad_middleware_permission_denied(self):
|
||||||
|
@ -722,8 +730,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Request Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Request Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, False, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, False, False, False, True, False)
|
||||||
|
|
||||||
def test_process_view_bad_middleware_permission_denied(self):
|
def test_process_view_bad_middleware_permission_denied(self):
|
||||||
|
@ -736,8 +744,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test View Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test View Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
self.assert_middleware_usage(post_middleware, True, False, False, True, False)
|
||||||
|
|
||||||
def test_process_response_bad_middleware_permission_denied(self):
|
def test_process_response_bad_middleware_permission_denied(self):
|
||||||
|
@ -750,9 +758,9 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Response Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Response Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
self.assert_middleware_usage(pre_middleware, True, True, False, False, True)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
def test_process_exception_bad_middleware_permission_denied(self):
|
def test_process_exception_bad_middleware_permission_denied(self):
|
||||||
pre_middleware = TestMiddleware()
|
pre_middleware = TestMiddleware()
|
||||||
|
@ -764,8 +772,8 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest):
|
||||||
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Exception Exception'])
|
self.assert_exceptions_handled('/middleware_exceptions/permission_denied/', ['Test Exception Exception'])
|
||||||
|
|
||||||
# Check that the right middleware methods have been invoked
|
# Check that the right middleware methods have been invoked
|
||||||
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
self.assert_middleware_usage(pre_middleware, True, True, False, True, False)
|
||||||
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(bad_middleware, True, True, False, True, True)
|
||||||
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
self.assert_middleware_usage(post_middleware, True, True, False, True, True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -177,15 +177,15 @@ class ReverseSelectRelatedTestCase(TestCase):
|
||||||
c = Child4.objects.create(name1='n1', name2='n2', value=1, value4=4)
|
c = Child4.objects.create(name1='n1', name2='n2', value=1, value4=4)
|
||||||
with self.assertNumQueries(1):
|
with self.assertNumQueries(1):
|
||||||
p = Parent2.objects.select_related('child1').only(
|
p = Parent2.objects.select_related('child1').only(
|
||||||
'id2', 'child1__value').get(name2="n2")
|
'id2', 'child1__value').get(name2="n2")
|
||||||
self.assertEqual(p.id2, c.id2)
|
self.assertEqual(p.id2, c.id2)
|
||||||
self.assertEqual(p.child1.value, 1)
|
self.assertEqual(p.child1.value, 1)
|
||||||
p = Parent2.objects.select_related('child1').only(
|
p = Parent2.objects.select_related('child1').only(
|
||||||
'id2', 'child1__value').get(name2="n2")
|
'id2', 'child1__value').get(name2="n2")
|
||||||
with self.assertNumQueries(1):
|
with self.assertNumQueries(1):
|
||||||
self.assertEqual(p.name2, 'n2')
|
self.assertEqual(p.name2, 'n2')
|
||||||
p = Parent2.objects.select_related('child1').only(
|
p = Parent2.objects.select_related('child1').only(
|
||||||
'id2', 'child1__value').get(name2="n2")
|
'id2', 'child1__value').get(name2="n2")
|
||||||
with self.assertNumQueries(1):
|
with self.assertNumQueries(1):
|
||||||
self.assertEqual(p.child1.name2, 'n2')
|
self.assertEqual(p.child1.name2, 'n2')
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ class ReverseSelectRelatedTestCase(TestCase):
|
||||||
def test_inheritance_deferred2(self):
|
def test_inheritance_deferred2(self):
|
||||||
c = Child4.objects.create(name1='n1', name2='n2', value=1, value4=4)
|
c = Child4.objects.create(name1='n1', name2='n2', value=1, value4=4)
|
||||||
qs = Parent2.objects.select_related('child1', 'child4').only(
|
qs = Parent2.objects.select_related('child1', 'child4').only(
|
||||||
'id2', 'child1__value', 'child1__child4__value4')
|
'id2', 'child1__value', 'child1__child4__value4')
|
||||||
with self.assertNumQueries(1):
|
with self.assertNumQueries(1):
|
||||||
p = qs.get(name2="n2")
|
p = qs.get(name2="n2")
|
||||||
self.assertEqual(p.id2, c.id2)
|
self.assertEqual(p.id2, c.id2)
|
||||||
|
|
|
@ -677,7 +677,7 @@ class TemplateTests(TransRealMixin, TestCase):
|
||||||
'basic-syntax06': ("{{ multi word variable }}", {}, template.TemplateSyntaxError),
|
'basic-syntax06': ("{{ multi word variable }}", {}, template.TemplateSyntaxError),
|
||||||
|
|
||||||
# Raise TemplateSyntaxError for empty variable tags
|
# Raise TemplateSyntaxError for empty variable tags
|
||||||
'basic-syntax07': ("{{ }}", {}, template.TemplateSyntaxError),
|
'basic-syntax07': ("{{ }}", {}, template.TemplateSyntaxError),
|
||||||
'basic-syntax08': ("{{ }}", {}, template.TemplateSyntaxError),
|
'basic-syntax08': ("{{ }}", {}, template.TemplateSyntaxError),
|
||||||
|
|
||||||
# Attribute syntax allows a template to call an object's attribute
|
# Attribute syntax allows a template to call an object's attribute
|
||||||
|
@ -1685,11 +1685,11 @@ class TemplateTests(TransRealMixin, TestCase):
|
||||||
'now01': ('{% now "j n Y" %}', {}, "%d %d %d" % (
|
'now01': ('{% now "j n Y" %}', {}, "%d %d %d" % (
|
||||||
datetime.now().day, datetime.now().month, datetime.now().year)),
|
datetime.now().day, datetime.now().month, datetime.now().year)),
|
||||||
# Check parsing of locale strings
|
# Check parsing of locale strings
|
||||||
'now02': ('{% now "DATE_FORMAT" %}', {}, date_format(datetime.now())),
|
'now02': ('{% now "DATE_FORMAT" %}', {}, date_format(datetime.now())),
|
||||||
# Also accept simple quotes - #15092
|
# Also accept simple quotes - #15092
|
||||||
'now03': ("{% now 'j n Y' %}", {}, "%d %d %d" % (
|
'now03': ("{% now 'j n Y' %}", {}, "%d %d %d" % (
|
||||||
datetime.now().day, datetime.now().month, datetime.now().year)),
|
datetime.now().day, datetime.now().month, datetime.now().year)),
|
||||||
'now04': ("{% now 'DATE_FORMAT' %}", {}, date_format(datetime.now())),
|
'now04': ("{% now 'DATE_FORMAT' %}", {}, date_format(datetime.now())),
|
||||||
'now05': ('''{% now 'j "n" Y'%}''', {}, '''%d "%d" %d''' % (
|
'now05': ('''{% now 'j "n" Y'%}''', {}, '''%d "%d" %d''' % (
|
||||||
datetime.now().day, datetime.now().month, datetime.now().year)),
|
datetime.now().day, datetime.now().month, datetime.now().year)),
|
||||||
'now06': ('''{% now "j 'n' Y"%}''', {}, '''%d '%d' %d''' % (
|
'now06': ('''{% now "j 'n' Y"%}''', {}, '''%d '%d' %d''' % (
|
||||||
|
|
|
@ -750,8 +750,8 @@ class TemplateTests(TestCase):
|
||||||
templates = {
|
templates = {
|
||||||
'notag': Template("{% load tz %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:ICT }}"),
|
'notag': Template("{% load tz %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:ICT }}"),
|
||||||
'noarg': Template("{% load tz %}{% localtime %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:ICT }}{% endlocaltime %}"),
|
'noarg': Template("{% load tz %}{% localtime %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:ICT }}{% endlocaltime %}"),
|
||||||
'on': Template("{% load tz %}{% localtime on %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:ICT }}{% endlocaltime %}"),
|
'on': Template("{% load tz %}{% localtime on %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:ICT }}{% endlocaltime %}"),
|
||||||
'off': Template("{% load tz %}{% localtime off %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:ICT }}{% endlocaltime %}"),
|
'off': Template("{% load tz %}{% localtime off %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:ICT }}{% endlocaltime %}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Transform a list of keys in 'datetimes' to the expected template
|
# Transform a list of keys in 'datetimes' to the expected template
|
||||||
|
@ -765,26 +765,26 @@ class TemplateTests(TestCase):
|
||||||
'utc': {
|
'utc': {
|
||||||
'notag': t('eat', 'eat', 'utc', 'ict'),
|
'notag': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'noarg': t('eat', 'eat', 'utc', 'ict'),
|
'noarg': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'on': t('eat', 'eat', 'utc', 'ict'),
|
'on': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'off': t('utc', 'eat', 'utc', 'ict'),
|
'off': t('utc', 'eat', 'utc', 'ict'),
|
||||||
},
|
},
|
||||||
'eat': {
|
'eat': {
|
||||||
'notag': t('eat', 'eat', 'utc', 'ict'),
|
'notag': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'noarg': t('eat', 'eat', 'utc', 'ict'),
|
'noarg': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'on': t('eat', 'eat', 'utc', 'ict'),
|
'on': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'off': t('eat', 'eat', 'utc', 'ict'),
|
'off': t('eat', 'eat', 'utc', 'ict'),
|
||||||
},
|
},
|
||||||
'ict': {
|
'ict': {
|
||||||
'notag': t('eat', 'eat', 'utc', 'ict'),
|
'notag': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'noarg': t('eat', 'eat', 'utc', 'ict'),
|
'noarg': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'on': t('eat', 'eat', 'utc', 'ict'),
|
'on': t('eat', 'eat', 'utc', 'ict'),
|
||||||
'off': t('ict', 'eat', 'utc', 'ict'),
|
'off': t('ict', 'eat', 'utc', 'ict'),
|
||||||
},
|
},
|
||||||
'naive': {
|
'naive': {
|
||||||
'notag': t('naive', 'eat', 'utc', 'ict'),
|
'notag': t('naive', 'eat', 'utc', 'ict'),
|
||||||
'noarg': t('naive', 'eat', 'utc', 'ict'),
|
'noarg': t('naive', 'eat', 'utc', 'ict'),
|
||||||
'on': t('naive', 'eat', 'utc', 'ict'),
|
'on': t('naive', 'eat', 'utc', 'ict'),
|
||||||
'off': t('naive', 'eat', 'utc', 'ict'),
|
'off': t('naive', 'eat', 'utc', 'ict'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,8 +397,8 @@ class NamespaceTests(TestCase):
|
||||||
self.assertEqual('/ns-outer/42/normal/', reverse('inc-outer:inc-normal-view', args=[42]))
|
self.assertEqual('/ns-outer/42/normal/', reverse('inc-outer:inc-normal-view', args=[42]))
|
||||||
self.assertEqual('/ns-outer/42/normal/37/4/', reverse('inc-outer:inc-normal-view', kwargs={'outer': 42, 'arg1': 37, 'arg2': 4}))
|
self.assertEqual('/ns-outer/42/normal/37/4/', reverse('inc-outer:inc-normal-view', kwargs={'outer': 42, 'arg1': 37, 'arg2': 4}))
|
||||||
self.assertEqual('/ns-outer/42/normal/37/4/', reverse('inc-outer:inc-normal-view', args=[42, 37, 4]))
|
self.assertEqual('/ns-outer/42/normal/37/4/', reverse('inc-outer:inc-normal-view', args=[42, 37, 4]))
|
||||||
self.assertEqual('/ns-outer/42/+%5C$*/', reverse('inc-outer:inc-special-view', kwargs={'outer': 42}))
|
self.assertEqual('/ns-outer/42/+%5C$*/', reverse('inc-outer:inc-special-view', kwargs={'outer': 42}))
|
||||||
self.assertEqual('/ns-outer/42/+%5C$*/', reverse('inc-outer:inc-special-view', args=[42]))
|
self.assertEqual('/ns-outer/42/+%5C$*/', reverse('inc-outer:inc-special-view', args=[42]))
|
||||||
|
|
||||||
def test_multiple_namespace_pattern(self):
|
def test_multiple_namespace_pattern(self):
|
||||||
"Namespaces can be embedded"
|
"Namespaces can be embedded"
|
||||||
|
|
Loading…
Reference in New Issue