summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/forms/__init__.py0
-rw-r--r--tests/regressiontests/forms/models.py0
-rw-r--r--tests/regressiontests/forms/tests.py481
-rw-r--r--tests/regressiontests/null_queries/__init__.py0
-rw-r--r--tests/regressiontests/null_queries/models.py54
-rw-r--r--tests/regressiontests/request_isolation/tests.py10
-rw-r--r--tests/regressiontests/templates/tests.py34
-rw-r--r--tests/regressiontests/thread_isolation/tests.py6
8 files changed, 569 insertions, 16 deletions
diff --git a/tests/regressiontests/forms/__init__.py b/tests/regressiontests/forms/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/regressiontests/forms/__init__.py
diff --git a/tests/regressiontests/forms/models.py b/tests/regressiontests/forms/models.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/regressiontests/forms/models.py
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py
new file mode 100644
index 0000000000..c4743a78a6
--- /dev/null
+++ b/tests/regressiontests/forms/tests.py
@@ -0,0 +1,481 @@
+"""
+>>> from django.newforms import *
+>>> import datetime
+>>> import re
+
+# TextInput Widget ############################################################
+
+>>> w = TextInput()
+>>> w.render('email', '')
+u'<input type="text" name="email" />'
+>>> w.render('email', None)
+u'<input type="text" name="email" />'
+>>> w.render('email', 'test@example.com')
+u'<input type="text" name="email" value="test@example.com" />'
+>>> w.render('email', 'some "quoted" & ampersanded value')
+u'<input type="text" name="email" value="some &quot;quoted&quot; &amp; ampersanded value" />'
+>>> w.render('email', 'test@example.com', attrs={'class': 'fun'})
+u'<input type="text" name="email" value="test@example.com" class="fun" />'
+
+You can also pass 'attrs' to the constructor:
+>>> w = TextInput(attrs={'class': 'fun'})
+>>> w.render('email', '')
+u'<input type="text" class="fun" name="email" />'
+>>> w.render('email', 'foo@example.com')
+u'<input type="text" class="fun" value="foo@example.com" name="email" />'
+
+'attrs' passed to render() get precedence over those passed to the constructor:
+>>> w = TextInput(attrs={'class': 'pretty'})
+>>> w.render('email', '', attrs={'class': 'special'})
+u'<input type="text" class="special" name="email" />'
+
+# Textarea Widget #############################################################
+
+>>> w = Textarea()
+>>> w.render('msg', '')
+u'<textarea name="msg"></textarea>'
+>>> w.render('msg', None)
+u'<textarea name="msg"></textarea>'
+>>> w.render('msg', 'value')
+u'<textarea name="msg">value</textarea>'
+>>> w.render('msg', 'some "quoted" & ampersanded value')
+u'<textarea name="msg">some &quot;quoted&quot; &amp; ampersanded value</textarea>'
+>>> w.render('msg', 'value', attrs={'class': 'pretty'})
+u'<textarea name="msg" class="pretty">value</textarea>'
+
+You can also pass 'attrs' to the constructor:
+>>> w = Textarea(attrs={'class': 'pretty'})
+>>> w.render('msg', '')
+u'<textarea class="pretty" name="msg"></textarea>'
+>>> w.render('msg', 'example')
+u'<textarea class="pretty" name="msg">example</textarea>'
+
+'attrs' passed to render() get precedence over those passed to the constructor:
+>>> w = Textarea(attrs={'class': 'pretty'})
+>>> w.render('msg', '', attrs={'class': 'special'})
+u'<textarea class="special" name="msg"></textarea>'
+
+# CheckboxInput Widget ########################################################
+
+>>> w = CheckboxInput()
+>>> w.render('is_cool', '')
+u'<input type="checkbox" name="is_cool" />'
+>>> w.render('is_cool', False)
+u'<input type="checkbox" name="is_cool" />'
+>>> w.render('is_cool', True)
+u'<input checked="checked" type="checkbox" name="is_cool" />'
+>>> w.render('is_cool', False, attrs={'class': 'pretty'})
+u'<input type="checkbox" name="is_cool" class="pretty" />'
+
+You can also pass 'attrs' to the constructor:
+>>> w = CheckboxInput(attrs={'class': 'pretty'})
+>>> w.render('is_cool', '')
+u'<input type="checkbox" class="pretty" name="is_cool" />'
+
+'attrs' passed to render() get precedence over those passed to the constructor:
+>>> w = CheckboxInput(attrs={'class': 'pretty'})
+>>> w.render('is_cool', '', attrs={'class': 'special'})
+u'<input type="checkbox" class="special" name="is_cool" />'
+
+# CharField ###################################################################
+
+>>> f = CharField(required=False)
+>>> f.to_python(1)
+u'1'
+>>> f.to_python('hello')
+u'hello'
+>>> f.to_python(None)
+u''
+>>> f.to_python([1, 2, 3])
+u'[1, 2, 3]'
+
+CharField accepts an optional max_length parameter:
+>>> f = CharField(max_length=10, required=False)
+>>> f.to_python('')
+u''
+>>> f.to_python('12345')
+u'12345'
+>>> f.to_python('1234567890')
+u'1234567890'
+>>> f.to_python('1234567890a')
+Traceback (most recent call last):
+...
+ValidationError: [u'Ensure this value has at most 10 characters.']
+
+CharField accepts an optional min_length parameter:
+>>> f = CharField(min_length=10, required=False)
+>>> f.to_python('')
+Traceback (most recent call last):
+...
+ValidationError: [u'Ensure this value has at least 10 characters.']
+>>> f.to_python('12345')
+Traceback (most recent call last):
+...
+ValidationError: [u'Ensure this value has at least 10 characters.']
+>>> f.to_python('1234567890')
+u'1234567890'
+>>> f.to_python('1234567890a')
+u'1234567890a'
+
+# IntegerField ################################################################
+
+>>> f = IntegerField()
+>>> f.to_python('1')
+1
+>>> isinstance(f.to_python('1'), int)
+True
+>>> f.to_python('23')
+23
+>>> f.to_python('a')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a whole number.']
+>>> f.to_python('1 ')
+1
+>>> f.to_python(' 1')
+1
+>>> f.to_python(' 1 ')
+1
+>>> f.to_python('1a')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a whole number.']
+
+# DateField ###################################################################
+
+>>> import datetime
+>>> f = DateField()
+>>> f.to_python(datetime.date(2006, 10, 25))
+datetime.date(2006, 10, 25)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30))
+datetime.date(2006, 10, 25)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30, 59))
+datetime.date(2006, 10, 25)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30, 59, 200))
+datetime.date(2006, 10, 25)
+>>> f.to_python('2006-10-25')
+datetime.date(2006, 10, 25)
+>>> f.to_python('10/25/2006')
+datetime.date(2006, 10, 25)
+>>> f.to_python('10/25/06')
+datetime.date(2006, 10, 25)
+>>> f.to_python('Oct 25 2006')
+datetime.date(2006, 10, 25)
+>>> f.to_python('October 25 2006')
+datetime.date(2006, 10, 25)
+>>> f.to_python('October 25, 2006')
+datetime.date(2006, 10, 25)
+>>> f.to_python('25 October 2006')
+datetime.date(2006, 10, 25)
+>>> f.to_python('25 October, 2006')
+datetime.date(2006, 10, 25)
+>>> f.to_python('2006-4-31')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date.']
+>>> f.to_python('200a-10-25')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date.']
+>>> f.to_python('25/10/06')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date.']
+>>> f.to_python(None)
+Traceback (most recent call last):
+...
+ValidationError: [u'This field is required.']
+
+>>> f = DateField(required=False)
+>>> f.to_python(None)
+>>> repr(f.to_python(None))
+'None'
+>>> f.to_python('')
+>>> repr(f.to_python(''))
+'None'
+
+DateField accepts an optional input_formats parameter:
+>>> f = DateField(input_formats=['%Y %m %d'])
+>>> f.to_python(datetime.date(2006, 10, 25))
+datetime.date(2006, 10, 25)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30))
+datetime.date(2006, 10, 25)
+>>> f.to_python('2006 10 25')
+datetime.date(2006, 10, 25)
+
+The input_formats parameter overrides all default input formats,
+so the default formats won't work unless you specify them:
+>>> f.to_python('2006-10-25')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date.']
+>>> f.to_python('10/25/2006')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date.']
+>>> f.to_python('10/25/06')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date.']
+
+# DateTimeField ###############################################################
+
+>>> import datetime
+>>> f = DateTimeField()
+>>> f.to_python(datetime.date(2006, 10, 25))
+datetime.datetime(2006, 10, 25, 0, 0)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30))
+datetime.datetime(2006, 10, 25, 14, 30)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30, 59))
+datetime.datetime(2006, 10, 25, 14, 30, 59)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30, 59, 200))
+datetime.datetime(2006, 10, 25, 14, 30, 59, 200)
+>>> f.to_python('2006-10-25 14:30:45')
+datetime.datetime(2006, 10, 25, 14, 30, 45)
+>>> f.to_python('2006-10-25 14:30:00')
+datetime.datetime(2006, 10, 25, 14, 30)
+>>> f.to_python('2006-10-25 14:30')
+datetime.datetime(2006, 10, 25, 14, 30)
+>>> f.to_python('2006-10-25')
+datetime.datetime(2006, 10, 25, 0, 0)
+>>> f.to_python('10/25/2006 14:30:45')
+datetime.datetime(2006, 10, 25, 14, 30, 45)
+>>> f.to_python('10/25/2006 14:30:00')
+datetime.datetime(2006, 10, 25, 14, 30)
+>>> f.to_python('10/25/2006 14:30')
+datetime.datetime(2006, 10, 25, 14, 30)
+>>> f.to_python('10/25/2006')
+datetime.datetime(2006, 10, 25, 0, 0)
+>>> f.to_python('10/25/06 14:30:45')
+datetime.datetime(2006, 10, 25, 14, 30, 45)
+>>> f.to_python('10/25/06 14:30:00')
+datetime.datetime(2006, 10, 25, 14, 30)
+>>> f.to_python('10/25/06 14:30')
+datetime.datetime(2006, 10, 25, 14, 30)
+>>> f.to_python('10/25/06')
+datetime.datetime(2006, 10, 25, 0, 0)
+>>> f.to_python('hello')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date/time.']
+>>> f.to_python('2006-10-25 4:30 p.m.')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date/time.']
+
+DateField accepts an optional input_formats parameter:
+>>> f = DateTimeField(input_formats=['%Y %m %d %I:%M %p'])
+>>> f.to_python(datetime.date(2006, 10, 25))
+datetime.datetime(2006, 10, 25, 0, 0)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30))
+datetime.datetime(2006, 10, 25, 14, 30)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30, 59))
+datetime.datetime(2006, 10, 25, 14, 30, 59)
+>>> f.to_python(datetime.datetime(2006, 10, 25, 14, 30, 59, 200))
+datetime.datetime(2006, 10, 25, 14, 30, 59, 200)
+>>> f.to_python('2006 10 25 2:30 PM')
+datetime.datetime(2006, 10, 25, 14, 30)
+
+The input_formats parameter overrides all default input formats,
+so the default formats won't work unless you specify them:
+>>> f.to_python('2006-10-25 14:30:45')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid date/time.']
+
+# RegexField ##################################################################
+
+>>> f = RegexField('^\d[A-F]\d$')
+>>> f.to_python('2A2')
+u'2A2'
+>>> f.to_python('3F3')
+u'3F3'
+>>> f.to_python('3G3')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid value.']
+>>> f.to_python(' 2A2')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid value.']
+>>> f.to_python('2A2 ')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid value.']
+
+Alternatively, RegexField can take a compiled regular expression:
+>>> f = RegexField(re.compile('^\d[A-F]\d$'))
+>>> f.to_python('2A2')
+u'2A2'
+>>> f.to_python('3F3')
+u'3F3'
+>>> f.to_python('3G3')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid value.']
+>>> f.to_python(' 2A2')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid value.']
+>>> f.to_python('2A2 ')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid value.']
+
+RegexField takes an optional error_message argument:
+>>> f = RegexField('^\d\d\d\d$', 'Enter a four-digit number.')
+>>> f.to_python('1234')
+u'1234'
+>>> f.to_python('123')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a four-digit number.']
+>>> f.to_python('abcd')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a four-digit number.']
+
+# EmailField ##################################################################
+
+>>> f = EmailField()
+>>> f.to_python('person@example.com')
+u'person@example.com'
+>>> f.to_python('foo')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid e-mail address.']
+>>> f.to_python('foo@')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid e-mail address.']
+>>> f.to_python('foo@bar')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid e-mail address.']
+
+# BooleanField ################################################################
+
+>>> f = BooleanField()
+>>> f.to_python(True)
+True
+>>> f.to_python(False)
+False
+>>> f.to_python(1)
+True
+>>> f.to_python(0)
+False
+>>> f.to_python('Django rocks')
+True
+
+# Form ########################################################################
+
+>>> class Person(Form):
+... first_name = CharField()
+... last_name = CharField()
+... birthday = DateField()
+>>> p = Person({'first_name': u'John', 'last_name': u'Lennon', 'birthday': u'1940-10-9'})
+>>> p.errors()
+{}
+>>> p.is_valid()
+True
+>>> p.errors().as_ul()
+u''
+>>> p.errors().as_text()
+u''
+>>> p.to_python()
+{'first_name': u'John', 'last_name': u'Lennon', 'birthday': datetime.date(1940, 10, 9)}
+>>> print p['first_name']
+<input type="text" name="first_name" value="John" />
+>>> print p['last_name']
+<input type="text" name="last_name" value="Lennon" />
+>>> print p['birthday']
+<input type="text" name="birthday" value="1940-10-9" />
+>>> for boundfield in p:
+... print boundfield
+<input type="text" name="first_name" value="John" />
+<input type="text" name="last_name" value="Lennon" />
+<input type="text" name="birthday" value="1940-10-9" />
+
+>>> p = Person({'last_name': u'Lennon'})
+>>> p.errors()
+{'first_name': [u'This field is required.'], 'birthday': [u'This field is required.']}
+>>> p.is_valid()
+False
+>>> p.errors().as_ul()
+u'<ul class="errorlist"><li>first_name<ul class="errorlist"><li>This field is required.</li></ul></li><li>birthday<ul class="errorlist"><li>This field is required.</li></ul></li></ul>'
+>>> print p.errors().as_text()
+* first_name
+ * This field is required.
+* birthday
+ * This field is required.
+>>> p.to_python()
+>>> repr(p.to_python())
+'None'
+>>> p['first_name'].errors
+[u'This field is required.']
+>>> p['first_name'].errors.as_ul()
+u'<ul class="errorlist"><li>This field is required.</li></ul>'
+>>> p['first_name'].errors.as_text()
+u'* This field is required.'
+
+>>> p = Person()
+>>> print p['first_name']
+<input type="text" name="first_name" />
+>>> print p['last_name']
+<input type="text" name="last_name" />
+>>> print p['birthday']
+<input type="text" name="birthday" />
+
+>>> class SignupForm(Form):
+... email = EmailField()
+... get_spam = BooleanField()
+>>> f = SignupForm()
+>>> print f['email']
+<input type="text" name="email" />
+>>> print f['get_spam']
+<input type="checkbox" name="get_spam" />
+
+>>> f = SignupForm({'email': 'test@example.com', 'get_spam': True})
+>>> print f['email']
+<input type="text" name="email" value="test@example.com" />
+>>> print f['get_spam']
+<input checked="checked" type="checkbox" name="get_spam" />
+
+Any Field can have a Widget class passed to its constructor:
+>>> class ContactForm(Form):
+... subject = CharField()
+... message = CharField(widget=Textarea)
+>>> f = ContactForm()
+>>> print f['subject']
+<input type="text" name="subject" />
+>>> print f['message']
+<textarea name="message"></textarea>
+
+as_textarea() and as_text() are shortcuts for changing the output widget type:
+>>> f['subject'].as_textarea()
+u'<textarea name="subject"></textarea>'
+>>> f['message'].as_text()
+u'<input type="text" name="message" />'
+
+The 'widget' parameter to a Field can also be an instance:
+>>> class ContactForm(Form):
+... subject = CharField()
+... message = CharField(widget=Textarea(attrs={'rows': 80, 'cols': 20}))
+>>> f = ContactForm()
+>>> print f['message']
+<textarea rows="80" cols="20" name="message"></textarea>
+
+Instance-level attrs are *not* carried over to as_textarea() and as_text():
+>>> f['message'].as_text()
+u'<input type="text" name="message" />'
+>>> f = ContactForm({'subject': 'Hello', 'message': 'I love you.'})
+>>> f['subject'].as_textarea()
+u'<textarea name="subject">Hello</textarea>'
+>>> f['message'].as_text()
+u'<input type="text" name="message" value="I love you." />'
+
+"""
+
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod()
diff --git a/tests/regressiontests/null_queries/__init__.py b/tests/regressiontests/null_queries/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/regressiontests/null_queries/__init__.py
diff --git a/tests/regressiontests/null_queries/models.py b/tests/regressiontests/null_queries/models.py
new file mode 100644
index 0000000000..09024f18c2
--- /dev/null
+++ b/tests/regressiontests/null_queries/models.py
@@ -0,0 +1,54 @@
+from django.db import models
+
+class Poll(models.Model):
+ question = models.CharField(maxlength=200)
+
+ def __str__(self):
+ return "Q: %s " % self.question
+
+class Choice(models.Model):
+ poll = models.ForeignKey(Poll)
+ choice = models.CharField(maxlength=200)
+
+ def __str__(self):
+ return "Choice: %s in poll %s" % (self.choice, self.poll)
+
+__test__ = {'API_TESTS':"""
+# Regression test for the use of None as a query value. None is interpreted as
+# an SQL NULL, but only in __exact queries.
+# Set up some initial polls and choices
+>>> p1 = Poll(question='Why?')
+>>> p1.save()
+>>> c1 = Choice(poll=p1, choice='Because.')
+>>> c1.save()
+>>> c2 = Choice(poll=p1, choice='Why Not?')
+>>> c2.save()
+
+# Exact query with value None returns nothing (=NULL in sql)
+>>> Choice.objects.filter(id__exact=None)
+[]
+
+# Valid query, but fails because foo isn't a keyword
+>>> Choice.objects.filter(foo__exact=None)
+Traceback (most recent call last):
+...
+TypeError: Cannot resolve keyword 'foo' into field
+
+# Can't use None on anything other than __exact
+>>> Choice.objects.filter(id__gt=None)
+Traceback (most recent call last):
+...
+ValueError: Cannot use None as a query value
+
+# Can't use None on anything other than __exact
+>>> Choice.objects.filter(foo__gt=None)
+Traceback (most recent call last):
+...
+ValueError: Cannot use None as a query value
+
+# Related managers use __exact=None implicitly if the object hasn't been saved.
+>>> p2 = Poll(question="How?")
+>>> p2.choice_set.all()
+[]
+
+"""}
diff --git a/tests/regressiontests/request_isolation/tests.py b/tests/regressiontests/request_isolation/tests.py
index b1c42d40bf..b83a424528 100644
--- a/tests/regressiontests/request_isolation/tests.py
+++ b/tests/regressiontests/request_isolation/tests.py
@@ -16,9 +16,9 @@ class MockHandler(WSGIHandler):
self.test = test
super(MockHandler, self).__init__()
- def get_response(self, path, request):
+ def get_response(self, request):
# debug("mock handler answering %s, %s", path, request)
- return HttpResponse(self.test(path, request))
+ return HttpResponse(self.test(request))
def debug(*arg):
@@ -50,7 +50,7 @@ class TestRequestIsolation(unittest.TestCase):
env['PATH_INFO'] = '/'
env['REQUEST_METHOD'] = 'GET'
- def request_one(path, request):
+ def request_one(request):
"""Start out with settings as originally configured"""
self.assertEqual(model_connection_name(MX), '_a')
self.assertEqual(
@@ -61,7 +61,7 @@ class TestRequestIsolation(unittest.TestCase):
MY._default_manager.db.connection.settings.DATABASE_NAME,
settings.OTHER_DATABASES['_b']['DATABASE_NAME'])
- def request_two(path, request):
+ def request_two(request):
"""Between the first and second requests, settings change to assign
model MY to a different connection
"""
@@ -74,7 +74,7 @@ class TestRequestIsolation(unittest.TestCase):
MY._default_manager.db.connection.settings.DATABASE_NAME,
settings.DATABASE_NAME)
- def request_three(path, request):
+ def request_three(request):
"""Between the 2nd and 3rd requests, the settings at the names in
OTHER_DATABASES have changed.
"""
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index e46b715490..bcb9c66254 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -173,6 +173,22 @@ class Templates(unittest.TestCase):
# Empty strings can be passed as arguments to filters
'basic-syntax36': (r'{{ var|join:"" }}', {'var': ['a', 'b', 'c']}, 'abc'),
+ ### COMMENT SYNTAX ########################################################
+ 'comment-syntax01': ("{# this is hidden #}hello", {}, "hello"),
+ 'comment-syntax02': ("{# this is hidden #}hello{# foo #}", {}, "hello"),
+
+ # Comments can contain invalid stuff.
+ 'comment-syntax03': ("foo{# {% if %} #}", {}, "foo"),
+ 'comment-syntax04': ("foo{# {% endblock %} #}", {}, "foo"),
+ 'comment-syntax05': ("foo{# {% somerandomtag %} #}", {}, "foo"),
+ 'comment-syntax06': ("foo{# {% #}", {}, "foo"),
+ 'comment-syntax07': ("foo{# %} #}", {}, "foo"),
+ 'comment-syntax08': ("foo{# %} #}bar", {}, "foobar"),
+ 'comment-syntax09': ("foo{# {{ #}", {}, "foo"),
+ 'comment-syntax10': ("foo{# }} #}", {}, "foo"),
+ 'comment-syntax11': ("foo{# { #}", {}, "foo"),
+ 'comment-syntax12': ("foo{# } #}", {}, "foo"),
+
### COMMENT TAG ###########################################################
'comment-tag01': ("{% comment %}this is hidden{% endcomment %}hello", {}, "hello"),
'comment-tag02': ("{% comment %}this is hidden{% endcomment %}hello{% comment %}foo{% endcomment %}", {}, "hello"),
@@ -473,7 +489,7 @@ class Templates(unittest.TestCase):
'i18n13': ('{{ _("Page not found") }}', {'LANGUAGE_CODE': 'de'}, 'Seite nicht gefunden'),
### HANDLING OF TEMPLATE_TAG_IF_INVALID ###################################
-
+
'invalidstr01': ('{{ var|default:"Foo" }}', {}, ('Foo','INVALID')),
'invalidstr02': ('{{ var|default_if_none:"Foo" }}', {}, ('','INVALID')),
'invalidstr03': ('{% for v in var %}({{ v }}){% endfor %}', {}, ''),
@@ -536,6 +552,8 @@ class Templates(unittest.TestCase):
'templatetag08': ('{% templatetag closebrace %}', {}, '}'),
'templatetag09': ('{% templatetag openbrace %}{% templatetag openbrace %}', {}, '{{'),
'templatetag10': ('{% templatetag closebrace %}{% templatetag closebrace %}', {}, '}}'),
+ 'templatetag11': ('{% templatetag opencomment %}', {}, '{#'),
+ 'templatetag12': ('{% templatetag closecomment %}', {}, '#}'),
### WIDTHRATIO TAG ########################################################
'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'),
@@ -606,20 +624,20 @@ class Templates(unittest.TestCase):
# Turn TEMPLATE_DEBUG off, because tests assume that.
old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False
-
- # Set TEMPLATE_STRING_IF_INVALID to a known string
+
+ # Set TEMPLATE_STRING_IF_INVALID to a known string
old_invalid = settings.TEMPLATE_STRING_IF_INVALID
-
+
for name, vals in tests:
install()
-
+
if isinstance(vals[2], tuple):
normal_string_result = vals[2][0]
invalid_string_result = vals[2][1]
else:
normal_string_result = vals[2]
invalid_string_result = vals[2]
-
+
if 'LANGUAGE_CODE' in vals[1]:
activate(vals[1]['LANGUAGE_CODE'])
else:
@@ -636,10 +654,10 @@ class Templates(unittest.TestCase):
continue
if output != result:
failures.append("Template test (TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Expected %r, got %r" % (invalid_str, name, result, output))
-
+
if 'LANGUAGE_CODE' in vals[1]:
deactivate()
-
+
loader.template_source_loaders = old_template_loaders
deactivate()
settings.TEMPLATE_DEBUG = old_td
diff --git a/tests/regressiontests/thread_isolation/tests.py b/tests/regressiontests/thread_isolation/tests.py
index 39c141720a..96f40c4af5 100644
--- a/tests/regressiontests/thread_isolation/tests.py
+++ b/tests/regressiontests/thread_isolation/tests.py
@@ -147,7 +147,7 @@ class TestThreadIsolation(unittest.TestCase):
finally:
self.lock.release()
- def request_one(self, path, request):
+ def request_one(self, request):
"""Start out with settings as originally configured"""
from django.conf import settings
debug("request_one: %s", settings.OTHER_DATABASES)
@@ -169,7 +169,7 @@ class TestThreadIsolation(unittest.TestCase):
self.assertEqual(connection.settings.DATABASE_NAME,
settings.DATABASE_NAME)
- def request_two(self, path, request):
+ def request_two(self, request):
"""Between the first and second requests, settings change to assign
model MY to a different connection
"""
@@ -196,7 +196,7 @@ class TestThreadIsolation(unittest.TestCase):
except:
self.add_thread_error(sys.exc_info())
- def request_three(self, path, request):
+ def request_three(self, request):
"""Between the 2nd and 3rd requests, the settings at the names in
OTHER_DATABASES have changed.
"""