From bec235deefbca44d1a9f3b95e453d946b1359135 Mon Sep 17 00:00:00 2001 From: Jason Pellerin Date: Mon, 14 Aug 2006 01:03:32 +0000 Subject: [multi-db] Merge trunk to [3578] git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3581 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/empty/models.py | 2 ++ tests/modeltests/lookup/models.py | 13 +++++++++++-- tests/othertests/defaultfilters.py | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/modeltests/empty/models.py b/tests/modeltests/empty/models.py index c50878398d..0f5a0b870f 100644 --- a/tests/modeltests/empty/models.py +++ b/tests/modeltests/empty/models.py @@ -20,5 +20,7 @@ API_TESTS = """ 2 >>> m.id is not None True +>>> existing = Empty(m.id) +>>> existing.save() """ diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py index a2c0a14158..55bb373a4b 100644 --- a/tests/modeltests/lookup/models.py +++ b/tests/modeltests/lookup/models.py @@ -15,7 +15,7 @@ class Article(models.Model): def __str__(self): return self.headline -API_TESTS = """ +API_TESTS = r""" # Create a couple of Articles. >>> from datetime import datetime >>> a1 = Article(headline='Article 1', pub_date=datetime(2005, 7, 26)) @@ -161,13 +161,14 @@ DoesNotExist: Article matching query does not exist. # Underscores and percent signs have special meaning in the underlying -# database library, but Django handles the quoting of them automatically. +# SQL code, but Django handles the quoting of them automatically. >>> a8 = Article(headline='Article_ with underscore', pub_date=datetime(2005, 11, 20)) >>> a8.save() >>> Article.objects.filter(headline__startswith='Article') [, , , , , , , ] >>> Article.objects.filter(headline__startswith='Article_') [] + >>> a9 = Article(headline='Article% with percent sign', pub_date=datetime(2005, 11, 21)) >>> a9.save() >>> Article.objects.filter(headline__startswith='Article') @@ -182,4 +183,12 @@ DoesNotExist: Article matching query does not exist. [, , , , , , , ] >>> Article.objects.exclude(headline="Article 7") [, , , , , , , ] + +# Backslashes also have special meaning in the underlying SQL code, but Django +# automatically quotes them appropriately. +>>> a10 = Article(headline='Article with \\ backslash', pub_date=datetime(2005, 11, 22)) +>>> a10.save() +>>> Article.objects.filter(headline__contains='\\') +[] + """ diff --git a/tests/othertests/defaultfilters.py b/tests/othertests/defaultfilters.py index 1636b948d0..9b1cfda833 100644 --- a/tests/othertests/defaultfilters.py +++ b/tests/othertests/defaultfilters.py @@ -231,6 +231,9 @@ False >>> time(datetime.time(13), "h") '01' +>>> time(datetime.time(0), "h") +'12' + # real testing is done in timesince.py, where we can provide our own 'now' >>> timesince(datetime.datetime.now() - datetime.timedelta(1)) '1 day' -- cgit v1.3