diff options
| author | Jason Pellerin <jpellerin@gmail.com> | 2006-07-16 23:11:33 +0000 |
|---|---|---|
| committer | Jason Pellerin <jpellerin@gmail.com> | 2006-07-16 23:11:33 +0000 |
| commit | 541ac3b990903056afaecd30ca013c39775fd9c5 (patch) | |
| tree | edb2c61940d74240a80dcaa11ec1589d893c50cc /tests | |
| parent | 49ce784805b9db3cc7523f2c391cc67f934dddca (diff) | |
[multi-db] Merge trunk to [3354]
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3355 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/m2m_and_m2o/models.py | 15 | ||||
| -rw-r--r-- | tests/othertests/templates.py | 17 | ||||
| -rwxr-xr-x | tests/runtests.py | 3 |
3 files changed, 19 insertions, 16 deletions
diff --git a/tests/modeltests/m2m_and_m2o/models.py b/tests/modeltests/m2m_and_m2o/models.py index 7a685ecbd2..f43fb12d9e 100644 --- a/tests/modeltests/m2m_and_m2o/models.py +++ b/tests/modeltests/m2m_and_m2o/models.py @@ -28,24 +28,23 @@ API_TESTS = """ >>> r.save() >>> g = User(username='gustav') >>> g.save() + >>> i = Issue(num=1) >>> i.client = r ->>> i.validate() -{} >>> i.save() + >>> i2 = Issue(num=2) >>> i2.client = r ->>> i2.validate() -{} >>> i2.save() >>> i2.cc.add(r) + >>> i3 = Issue(num=3) >>> i3.client = g ->>> i3.validate() -{} >>> i3.save() >>> i3.cc.add(r) + >>> from django.db.models.query import Q + >>> Issue.objects.filter(client=r.id) [<Issue: 1>, <Issue: 2>] >>> Issue.objects.filter(client=g.id) @@ -55,8 +54,8 @@ API_TESTS = """ >>> Issue.objects.filter(cc__id__exact=r.id) [<Issue: 2>, <Issue: 3>] -# Queries that combine results from the m2m and the m2o relationship. -# 3 ways of saying the same thing: +# These queries combine results from the m2m and the m2o relationships. +# They're three ways of saying the same thing. >>> Issue.objects.filter(Q(cc__id__exact=r.id) | Q(client=r.id)) [<Issue: 1>, <Issue: 2>, <Issue: 3>] >>> Issue.objects.filter(cc__id__exact=r.id) | Issue.objects.filter(client=r.id) diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py index d3b09c5310..3d23d8123b 100644 --- a/tests/othertests/templates.py +++ b/tests/othertests/templates.py @@ -1,5 +1,9 @@ from django.conf import settings +if __name__ == '__main__': + # When running this file in isolation, we need to set up the configuration + # before importing 'template'. + settings.configure() from django import template from django.template import loader @@ -538,10 +542,10 @@ TEMPLATE_TESTS = { ### TIMESINCE TAG ################################################## # Default compare with datetime.now() - 'timesince01' : ('{{ a|timesince }}', {'a':datetime.now() + timedelta(minutes=-1)}, '1 minute'), - 'timesince02' : ('{{ a|timesince }}', {'a':(datetime.now() - timedelta(days=1))}, '1 day'), + 'timesince01' : ('{{ a|timesince }}', {'a':datetime.now() + timedelta(minutes=-1, seconds = -10)}, '1 minute'), + 'timesince02' : ('{{ a|timesince }}', {'a':(datetime.now() - timedelta(days=1, minutes = 1))}, '1 day'), 'timesince03' : ('{{ a|timesince }}', {'a':(datetime.now() - - timedelta(hours=1, minutes=25))}, '1 hour, 25 minutes'), + timedelta(hours=1, minutes=25, seconds = 10))}, '1 hour, 25 minutes'), # Compare to a given parameter 'timesince04' : ('{{ a|timesince:b }}', {'a':NOW + timedelta(days=2), 'b':NOW + timedelta(days=1)}, '1 day'), @@ -552,9 +556,9 @@ TEMPLATE_TESTS = { ### TIMEUNTIL TAG ################################################## # Default compare with datetime.now() - 'timeuntil01' : ('{{ a|timeuntil }}', {'a':datetime.now() + timedelta(minutes=2)}, '2 minutes'), - 'timeuntil02' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(days=1))}, '1 day'), - 'timeuntil03' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(hours=8, minutes=10))}, '8 hours, 10 minutes'), + 'timeuntil01' : ('{{ a|timeuntil }}', {'a':datetime.now() + timedelta(minutes=2, seconds = 10)}, '2 minutes'), + 'timeuntil02' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(days=1, seconds = 10))}, '1 day'), + 'timeuntil03' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(hours=8, minutes=10, seconds = 10))}, '8 hours, 10 minutes'), # Compare to a given parameter 'timeuntil04' : ('{{ a|timeuntil:b }}', {'a':NOW - timedelta(days=1), 'b':NOW - timedelta(days=2)}, '1 day'), @@ -621,5 +625,4 @@ def run_tests(verbosity=0, standalone=False): raise Exception, msg if __name__ == "__main__": - settings.configure() run_tests(1, True) diff --git a/tests/runtests.py b/tests/runtests.py index b712d1352a..8dc48415ee 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -154,8 +154,9 @@ class TestRunner: # Manually set INSTALLED_APPS to point to the test models. settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS + ['.'.join(a) for a in get_test_models()] - # Manually set DEBUG = False. + # Manually set DEBUG and USE_I18N. settings.DEBUG = False + settings.USE_I18N = True self.output(0, "Running tests with database %r" % settings.DATABASE_ENGINE) |
